LARAVEL: Updating Autoload and Composer files

By PNC No comments

So! You’ve added a new class or even a new controller.  Added the view link in your route (web.php) or even in your API (api.php).

Everything are working, but after deploying the app to your host, the newly created class or controller is missing.

This is because the bootstrap or the composer autoload files were not updated.  There are times that you need to update the vendor composer file (specifically autoload_classmap.php) for your new class to get recognized.

Here is a quick tip before you update that file manually.  To update the list of your app libraries and remove all cache, here are the commands you need to execute on your terminal or console:

php artisan clear-compiled
composer dump-autoload
php artisan optimize:clear

php artisan clear-compiled.  Will clear the compiled classes and services in your application that has been cached.

composer dump-autoload.  Will regenerate the list of classes that are included in the app. This is the autoload_classmap.php file which you need to include during deployment of updates.  This file can be found at the vendor/composer folder.

php artisan optimize:clear.  Lastly, this command will clear all kinds of cache at once from your app.  The reason why Laravel cache the app is for faster loading.

Now you know.  I hope this helps.  Good luck!