Laravel migrations: Class "not found" Laravel migrations: Class "not found" symfony symfony

Laravel migrations: Class "not found"


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": [        "app/database/migrations"    ],    "psr-4": {        "Acme\\controllers\\": "app/controllers"    }}

Then run:

php artisan clear-compiled php artisan optimize:clearcomposer dump-autoloadphp artisan optimize
  • First one clears all compiled autoload files.
  • Second clears Laravel caches (optional)
  • Third builds the autoloader for namespaced classes.
  • Fourth optimizes various parts of your Laravel app and builds the autoloader for non-namespaced classes.

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


Simply make sure your migration filename is the same as your class name.

i.e:

If filename is:

xxx_151955_create_post_translations_table.php

Then class should be:

CreatePostTranslationsTable


If you get the "Class not found error" when running migrations, please try running this command.

composer dump-autoload 

then re-issuing the migrate command. See more details in the offical site (#Running Migrations): http://laravel.com/docs/master/migrations#running-migrations