Laravel migrations: Class “not found”

前端 未结 16 1521
自闭症患者
自闭症患者 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:19

    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:clear
    composer dump-autoload
    php 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.

提交回复
热议问题