Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'Controllers\Admin\User' not found
<?php namespace Controllers\Admin;
class UserStoreController extends BaseController{
Location of my Controller is app>controllers>admin>UserStoreController.php
It would work well outside admin folder, but once it's in admin folder it would fail.
I also tried PSR-0 on composer.phar autoload & use app\models\user;
basically i'm just trying to use laravel's ORM but i cant because the controller is in the folder.
Any idea how i could go around this issue?
You need to update the autoloader
composer dump-autoload
As JeannotLapin said, update the composer autoloader or add the path to Laravels built-in autoloading: /app/start/global.php, method ClassLoader::addDirectories()
Related
Sorry if my question looks so basic...
Am trying to use the following package in a fresh Laravel7 installation.
https://github.com/phpclassic/php-shopify
As like they mentioned i used 'composer require phpclassic/php-shopify' command to install this package. It is done successfully and i see it under 'Vendor/phpclassic/php-shopify/' folder. Now i want to use it in my controller...
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use PHPShopify\ShopifySDK;
class ShopifyConnectionController extends Controller
{
function index(Request $request){
$config = array(
'ShopUrl' => config('app.shopify_app_url'),
'ApiKey' => config('app.shopify_app_api_key'),
'SharedSecret' => config('app.shopify_app_api_secret'),
);
PHPShopify\ShopifySDK::config($config);
dd($request->all());
}
}
?>
Am getting following error...
Error
Class 'App\Http\Controllers\PHPShopify\ShopifySDK' not found
Now i see that the package is not auto loaded. I tried using "composer dump-autoload" command and tried adding the folder path in autoload section of composer.json file, etc... am keep getting the same error... I also noticed the "composer dump-autoload" command showing...
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
etc...
but not the package i installed. Those discovered packages also in the same vendor folder. Then why is my package is not being discovered by Composer autoload when i run that command ? Someone kindly help.
You are simply missing a backslash. This tells the autoloader that the file you are looking for is not in the namespace your controller resides in.
\PHPShopify\ShopifySDK::config($config);
And since you've already imported ShopifySDK there's no need for a FQCN. Just use the class:
ShopifySDK::config($config);
I have a composer based TYPO3 7.6 installation and want to create an Extbase extension with a command controller.
The controller is registered in ext_localconf.php but the commmand controller isn't found because the class is not found in typo3/sysext/extbase/Classes/Mvc/Cli/CommandManager.php in public function getAvailableCommands()
Namespace is also set: namespace Foo\FooT3monitoringNotification\Command;
The class is here Classes/Command/NotificationCommandController.php.
I've cleared all TYPO3 caches and did composer dump-autoload. Any idea, what I missed to do or what I can do to find out, why my class isn't put to autoload?
As your newly created extension is not installed via composer, you need to define where to look for the classes. Therefore you need to add an autoload section to your root composer.json (that' means not in your extension, but in your TYPO3 distribution root folder):
"autoload": {
"psr-4": {
"Foo\\FooT3monitoringNotification\\": "web/typo3conf/ext/foo_t3monitoring_notification/Classes"
}
}
More information: https://usetypo3.com/typo3-and-composer.html#c67
I have an existing PHP project. I need to test a class MyClass. I created a test under the same package.
When running with IntelliJ 2016.1 I get error Fatal error: Class 'MyClass' not found in
This is example of the test
<?php
class MyClassTest extends PHPUnit_Framework_TestCase
In Run Configuration I entered Custom working directory as the Composer vendor package.
PHPUnit is loaded from the include path
Under Settings->PHP I added the phpunit Composer package and my class package to the include path.
Under Settings->PHP->PHPUnit default config file and default bootstrap are unchecked.
What else should I configure so I can run MyClassTest without errors and test the class MyClass?
If the class is part of a composer package, or you use the composer autoloader for your project files, you can set up vendor/autoload.php as bootstrap file.
If you have set up a custom autoloader for project classes, you need to create your own boostrap.php file for PHPUnit and register the autoloader there.
I changed my folder structure and namespaces in my project. Previously I used the following namespace in my controllers:
App\Http\Controllers\FrontEnd\
I changed my folder structure and changed all my namespaces to
App\Http\FrontEnd\Controllers\
I run:
composer self-update
Then I run:
composer dump-autoload -o
Finally I run:
composer update
Everything updated successfully then at the end of it all I get this error:
[ReflectionException]
Class App\Http\Controllers\FrontEnd\Auth\AuthController does not exist
The only think I can think of is that I forgot to change something somewhere important.
You need to look in your project file usages of AuthController. You said that you change folder structure to App\Http\FrontEnd\Controllers\ and as you see for AuthController you get error App\Http\Controllers\FrontEnd\Auth\AuthController so probably somewhere in your code you have: Auth\AuthController:...
"Class ModelName not found", "Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)" is showing while using ModelName::find(1) in the controller which have a namespace of Controllers\admin and model is without any namespace. on the top of file, i applied use ModelName;. after following many guides, i applied php composer dump-autoload and composer du.
still shows model not found. what is the reason and how to use ModelName using Eloquont ?