Laravel Alias not finding class Laravel Alias not finding class laravel laravel

Laravel Alias not finding class


php artisan config:clear

Might help also. In case you have previously cached config files with config:cache since aliases are defined in app config.


First run composer dump-autoload to make sure the class can be found.

Now, when you have controller in namespace, for example:

<?phpnamespace App\Http\Controllers;class YourController {}

if you want to access FrontendAssets class you need to add leading backslash, so FrontendAssets::assets(); won't work but \FrontendAssets::assets(); will work.

You can alternatively import this class:

<?phpnamespace App\Http\Controllers;use FrontendAssets;class YourController {}

and now you will be able to use FrontendAssets::assets();. If it's unclear you might want to look also for explanation at How to use objects from other namespaces and how to import namespaces in PHP


Laravel caches the configuration to avoid runtime loading overhead. You have to run one of the given artisan commands,

below given command will clear out the configurations cached previously.

php artisan config:clear

and the below given command will clear and re-cache the configuration.

php artisan config:cache

After clearing the configuration cache, You will be able to user that Alise definde in config/app.php. Hop this helps.