Laravel Fatal Error Class Not Found when migrating

后端 未结 11 2113
后悔当初
后悔当初 2021-02-02 11:39
  1. I\'ve run artisan migrate:reset.

  2. I\'ve deleted some of my migration files because I didn\'t need these tables anymore.

  3. I

相关标签:
11条回答
  • 2021-02-02 12:12

    I solved my problem by

    1. Removing all migration
    2. Running composer dump-autoload
    3. Adding them back one by one and running php artisan migrate
    4. Deleting those that caused Laravel to throw an error
    5. Create new migrations to replace the deleted ones

    I'm not sure why that worked but my guess is that I might have modified the class name of these problematic migrations in the past.

    I also found that renaming the migration with its initial name (The one throwed with the fatal error) also works for some of them.

    0 讨论(0)
  • 2021-02-02 12:12

    If artisan doesn't work at all and keeps throwing you this message no matter the command you give, delete the config.php file from bootstrap/cache folder.

    After that run again

    php artisan config:cache
    
    0 讨论(0)
  • 2021-02-02 12:13

    version 5.1.3 same problem fix it me:

    • drop database all tables
    • php artisan migrate:status

    output: No migrations found. ok use it

    • php artisan migrate:install
    • php artisan migrate

    output is:

    Migrated: 2016_11_24_093015_dt_some_table
    Migrated: 2016_12_05_141004_dt_some_table
    Migrated: 2016_12_07_110518_dt_some_table
    Migrated: 2016_12_08_141807_dt_some_table
    Migrated: 2016_12_13_090832_dt_some_table
    

    this problem is solved

    0 讨论(0)
  • 2021-02-02 12:17

    I know this is a bit past but there is a better way actually. Run the following in terminal and feel free yourself to remove any of them:

    ~$ php artisan clear-compiled;php artisan cache:clear;php artisan config:clear;php artisan debugbar:clear;php artisan view:clear;php artisan optimize
    

    To do it a regular task create an executable file named artisan-clear:

    #!/bin/bash
    
    php artisan clear-compiled
    php artisan cache:clear
    php artisan config:clear
    php artisan debugbar:clear
    php artisan view:clear
    php artisan optimize
    
    0 讨论(0)
  • 2021-02-02 12:20

    I had this problem too. Must remember: class name must be in accordance with filename. Simple file renaming helped me:)

    For example: in file "2014_12_08_100923_create_items_tables.php" must be class with name "CreateItemsTables" with using CamelCase words.

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