Laravel migrations: Class “not found”

前端 未结 16 1438
自闭症患者
自闭症患者 2020-12-12 14:38

I am deploying a Laravel barebone project to Microsoft Azure, but whenever I try to execute php artisan migrate I get the error:

[2015-06-13

相关标签:
16条回答
  • 2020-12-12 15:22

    Make sure your migrations filename matches with migration class name

    FOR EXAMPLE:

    If name of migration is:

    2020_10_31_161839_create_notifications_table

    Then the class name should be:

    CreateNotificationsTable

    0 讨论(0)
  • 2020-12-12 15:24

    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

    0 讨论(0)
  • 2020-12-12 15:26

    In my case was the auto-increment of the database, In the past I did remove manually one entry, and AUTO_INCREMENT was pointing one more than the next id in the table.

    Apparently Laravel uses AUTO_INCREMENT-1 to know which was the last migration done.

    0 讨论(0)
  • 2020-12-12 15:27

    I had a similar situation (class not found error) after moving a Laravel 5.2 dev project to production. The production server was looking for class "project" but the controller name was Project.php. Once I renamed the file to project.php it was good to go.

    0 讨论(0)
  • 2020-12-12 15:28

    For me, the problem was that I had named my migration 2017_12_15_012645_create_modules_problems.php, with the class name of CreateModulesProblemsTable. As soon as I added _table to the filename, everything worked fine.

    0 讨论(0)
  • 2020-12-12 15:32

    I had this same problem a while back. Apparently it is a common problem because in the documentation for Laravel, it even suggests it: http://laravel.com/docs/master/migrations#running-migrations

    Basically all you have to do is refresh some composer files. Simply run:

    composer dump-autoload

    This will refresh composer autoload files and then you can run your normal migration and it should work! Very best.

    0 讨论(0)
提交回复
热议问题