I added a class in a new folder under the folder "app".
Inside this class I cannot access:
App::environment();
This does not work either:
\App::environment();
I am using this class in a script that I am running from command line.
I guess I am not bootstrapping the app correctly but I cannot figure out how.
Here is the calling script:
require __DIR__.'/../bootstrap/autoload.php';
use App\Scripts\SqlMigrator;
$sqlMigrator = new SqlMigrator();
I tried to import this in the class:
use Illuminate\Support\Facades\App;
but then I get this error:
PHP Fatal error: Uncaught exception 'RuntimeException' with message 'A facade root has not been set.'
Updating with what I got so far:
It seems close in the test class: When I use this:
$environment = app()->environment();
It gives me this error:
ReflectionException: Class env does not exist
Is this a hint for you?
Thanks
try to import app class as below
use App;
Related
I have created login_model.php file my models folder.But When I am executing the function,It gives the error.But it Works fine on local server but after uploading only it gives error.
Please help me out.Thanks In Advance.
The filename is case-sensitive, should be Login_model.php, and should declare class Login_model extends CI_Model again note the capitalization.
Then assuming this file is not in a sub-folder in application/models the model can be loaded via $this->load->model('login_model');
UPDATE: I managed to resolve the issue by completely removing the vendor directory, and re-running the composer install command. I still don't know what was the actual cause of this beahviour, but at least it's working now.
I've been tasked to troubleshoot and improve an application written in Laravel.
Since I almost always worked in Codeigniter, my knowledge of Laravel boils down to "I know what it is and where to download it from" :)
So, the application fails with the the following error:
PHP Warning: Uncaught ErrorException: require(\Repos\PermissionRepo.php): failed to open stream: No such file or directory in \wwwroot\app\Repos\PermissionRepo.php:5
the PermissionRepo file looks like this:
2: namespace Wckphma\Repos;
3:
4: use Illuminate\Support\Facades\Auth;
5: use Wckphma\User;
the seemingly missing Wckphma\User declaration file does exist, and the beginning of the file looks like this:
namespace Wckphma;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Wckphma\Repos\GroupRepo;
use Wckphma\Repos\PermissionRepo;
class User extends Authenticatable
{
****
It cannot be the file permissions, as in pure desperation I gave all the user read/write permissions to all files throughout.
Any ideas, what this might be?
I am trying to generate CRUD using command line in Symfony3 I am getting error as below
I tried clearing cache using below command line
php bin/console cache:clear
Still I am getting this error.
You need to generate/create the bundle AcmeBlogBundle first and add the bundle to the kernel in app/AppKernel.php.
Otherwise Doctrine doesn't know about the alias AcmeBlogBundle: that is used to resolve the class to an entity. Doctrine can't resolve the alias to an existing namespace and doesn't know where to put the Entity class.
Run the following command to create i.e. the AcmeBlogBundle bundle.
app/console generate:bundle --namespace=Acme\Bundle\AcmeBlogBundle
Your AppKernel.php should now contain the line:
public function registerBundles()
{
$bundles = array(
// ...
new Acme\Bundle\AcmeBlogBundle(),
);
// ...
return $bundles;
Afterwards the error message will be gone and you'll be able to generate your Entity with:
app/console doctrine:generate:crud --entity=AcmeBlogBundle:Entity
Suddenly our Magento store has a fatal error:
PHP Fatal error: Class 'Zend_Uri' not found in /.../public_html/app/code/core/Mage/Core/Model/Store.php on line 726
No new plugins or modules have been added recently.
Compiler is not active, var/cache and var/session are empty.
Permissions are resetted for all magento folders / files.
No other errors or more information is provided, but i have a blank page - on frontend and backend.
Magento version 1.7.0.2. Any help appreciated.
Line 726 of the Store.php file looks like this
#File: app/code/core/Mage/Core/Model/Store.php
$uri = Zend_Uri::factory($secureBaseUrl);
That is, Magento's making a call to the static method factory on the Zend_Uri class. Your error
PHP Fatal error: Class 'Zend_Uri' not found
Indicates that PHP can't find the Zend_Uri class. This could be because
The class definition file is no longer there,
Someone has changed the class definition file so it's no longer valid
A local code pool override file exists and someone has edited the class override file so it's no longer valid
Someone has edited the lib/Varien/Autoload.php so it can't load the Zend_Uri class file
A local code pool override file exists for Varien/Autoload.php and someone has edited it so it can't load the Zend_Uri class file
Someone has changed the php include path (normally defined in app/Mage.php) so it doesn't include the lib folder, or the code pool where a local code pool override might exist
I'd start by looking for the Zend_Uri class in lib/Zend/Uri.php, and then work your way down the list until you figure out why PHP isn't autoloading this class file.
I get phpunit and install it as this link using the simplest way for test purposes.
I just download the phpunit.phar file, chmod & rename & move to /usr/local/bin Then, I run phpunit --version, its ok.
PHPUnit 3.7.27 by Sebastian Bergmann
I write a simple test
public function testSomething(){
$this -> assertTrue(true)
}
Then I go into the source file folder, phpunit --colors Test
It works. So, I decide write a complex demo.
My project folder structure is like this.
Project Name
--> app
--> api
--> tests
Now I write a simple class in app/api/FlyApi.php
<?php
class FlyApi {
public function makeFly(){
//do something else
}
}
Then I write another test class for FlyApi.php
<?php
class FlyApiTest extends PHPUnit_Framework_TestCase {
public function testFly(){
//new a FlyApi
$flyApi = new FlyApi();
//do something
}
}
At this line $flyApi = new FlyApi() I got the error.
PHP Fatal error: Class 'FlyApi' not found in /home/kevin/Workspace/fly/app/api/FlyApi.php on line 23
Yes, this line $flyApi = new FlyApi()
You didn't load the definition of your FlyApi class.
This solution is Laravel specific:
You should be extending TestCase rather than PHPUnit_Framework_TestCase.
Try adding your /api/ folder into your ClassLoader at app\start\global.php.
You will find this section:
ClassLoader::addDirectories(array(
app_path().'/commands',
app_path().'/controllers',
...
app_path().'/api/
));
Are you using Laravel's phpunit.xml file? It includes Laravel's (and Composer's) autoload.php file which lets you use all your autoloaded classes within it.
Finally, what's the whole error? It should (hopefully) tell you what class it's trying to load (which will give you clues if the namespace is wrong or something).