部署Laravel Forge投掷faker未找到例外

时间:2015-09-26 19:36:12

标签: php laravel laravel-5.1 laravel-forge

我正在尝试在forge上部署一个laravel项目,我得到以下异常:

Symfony\Component\Debug\Exception\FatalErrorException]  
Class 'Faker\Factory' not found     

我在composer.json中的require-dev中有faker引用!

composer.json文件

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.1.*",
    "tymon/jwt-auth": "0.5.*",
    "dingo/api": "1.0.x@dev"
},
"require-dev": {
    "fzaninotto/faker": "~1.5",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~4.0",
    "phpspec/phpspec": "~2.1",
    "laracasts/testdummy": "1.*",
    "laracasts/generators": "^1.1"
},
"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},
"autoload-dev": {
    "classmap": [
        "tests/TestCase.php"
    ]
},
"scripts": {
    "post-install-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "pre-update-cmd": [
        "php artisan clear-compiled"
    ],
    "post-update-cmd": [
        "php artisan optimize"
    ],
    "post-root-package-install": [
        "php -r \"copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ]
},
"config": {
    "preferred-install": "dist"
}

}

Forge中的部署脚本:

git pull origin master 
composer install --no-interaction --no-dev --prefer-dist
php artisan migrate --force
php artisan db:seed --class="StaticDataSeeder"

我能够在本地部署同一个项目而没有任何问题,并且forge上的composer更新也成功运行,我可以看到faker包被下载。

如果我错过了什么,请告诉我。

1 个答案:

答案 0 :(得分:17)

有明显的冲突可以解释您的问题:

  1. 您已将"fzaninotto/faker"个包添加到require-dev部分。

  2. 您正在使用composer install选项运行部署--no-dev命令,explicitly prohibits安装require-dev中列出的软件包。

  3. 因此,解决方案是将包移至require部分,或在部署时删除--no-dev选项。