简体   繁体   中英

Laravel - can't install from my source control

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"
    }
}

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.
    ]

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM