douzao1119
douzao1119
2016-11-09 20:08

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

I need to automate my laravel project setup/upgrade on my production machine from source control.

I wrote a bash script to clone the source from the GIT repo and run the setup.

The git code is going to the folder /var/www/prod/mainapp/, so the following bash code is running after the git command:

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

I am getting the following error when the code reaches to: 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

in my app.php i have the following providers:

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

this is my 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条回答

  • du1913 du1913 5年前

    You need to add to the classmap the line that will tell who should be autoloaded. app/Providers

    "classmap": [
            "database",
            "app/Facades",
             "app/Services",
             "app/Providers" //this is the missing part.
        ]
    
    点赞 评论 复制链接分享
  • douqi5079 douqi5079 5年前

    I've come across this a few times.

    My workaround is to run

    composer install --no-scripts
    

    You are getting that error due to the pre install scripts in your composer.json file and by adding that flag to the install process you skip these scripts.

    Once you have everything installed you can then just use composer install and composer update as you usually would.

    点赞 评论 复制链接分享

相关推荐