我需要从源代码管理中自动化我的生产机器上的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"
}
}
答案 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 install
和composer update
。