Laravel migrations: Class “not found” 1


For PSR-4 Auto Loader Users (composer.json):

Keep the migrations folder inside classmap array and do not include it inside psr-4 object under autoload head. As migrations' main class Migrator doesn't support namespacing. For example;

"autoload": {
    "classmap": [
    "psr-4": {
        "Acme\\controllers\\": "app/controllers"

Then run:

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

  1. First one clears all compiled autoload files.
  2. Second clears Laravel caches (optional)
  3. Third build the autoloader for namespaced classes.
  4. Fourth optimize various parts of your Laravel app and builds the autoloader for non-namespaced classes.

From this time onwards, you will not have to do this again and any new migrations will work correctly.