Laravel - 无法从我的源代码管理器安装

时间:2016-11-09 20:08:57

标签: php git bash laravel

我需要从源代码管理中自动化我的生产机器上的laravel项目设置/ 升级

我编写了一个bash脚本来克隆GIT仓库中的源并运行安装程序。

git代码将转到文件夹/var/www/prod/mainapp/,因此以下bash代码在git命令之后运行:

cd /var/www/prod/mainapp/app/
composer install # composer update will not work as well
php artisan dump-autoload
php artisan optimize

当代码到达:php artisan optimize

时,我收到以下错误

PHP Fatal error: Class 'App\Providers\SocialUserProvider' not found in /var/www/prod/mainapp/app/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146

在我的app.php中,我有以下提供商:

    App\Providers\FacebookGraphProvider::class,
    Torann\GeoIP\GeoIPServiceProvider::class,
    App\Providers\SocialUserProvider::class,

这是我的composer.json:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "torann/geoip": "0.2.3"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "symfony/css-selector": "2.8.*|3.0.*",
        "symfony/dom-crawler": "2.8.*|3.0.*"
    },
    "autoload": {
        "classmap": [
            "database",
            "app/Facades",
             "app/Services"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

2 个答案:

答案 0 :(得分:1)

您需要在classmap中添加一行,告诉谁应该自动加载。 app/Providers

"classmap": [
        "database",
        "app/Facades",
         "app/Services",
         "app/Providers" //this is the missing part.
    ]

答案 1 :(得分:0)

我偶然发现过几次。

我的解决方法是运行

composer install --no-scripts

由于composer.json文件中的预安装脚本而导致该错误,并且在安装过程中将该标志添加到您跳过这些脚本。

安装好所有内容后,您就可以像往常一样使用composer installcomposer update