1

当我尝试使用此部署脚本使用 Forge 进行部署时:

cd /home/forge/default
git pull origin master
cd /home/forge/default/server
composer install --no-interaction --no-dev --prefer-dist
php artisan migrate --force

它失败并抛出下面的错误。我在 composer.json 中使用这些依赖项,并且在 require 中没有开发依赖项。

作曲家.json

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.1.*",
    "nesbot/carbon": "~1.14",
    "guzzlehttp/guzzle": "^6.0",
    "tymon/jwt-auth": "0.5.*",
    "barryvdh/laravel-cors": "^0.7.0"
},
"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~4.0",
    "phpspec/phpspec": "~2.1",
    "barryvdh/laravel-debugbar": "~2.0"
},

错误

  [Symfony\Component\Debug\Exception\FatalErrorException]  
  Class 'Barryvdh\Debugbar\ServiceProvider' not found

如何解决此问题,以便部署不会引入开发依赖项,但不必更改提供程序设置以进行开发?或者,我是否应该不费心设置 --no-dev 并拉入所有内容?当我放弃 --no-dev 标志时工作。

4

1 回答 1

2

我自己也使用 DebugBar,然后用 composer 把所有东西都拉进去。我只在我的开发机器上显示调试栏:

// AppServiceProvider.php

public function register()
{
    if ($this->app->environment('local')) {
        // register the service provider
        $this->app->register('Barryvdh\Debugbar\ServiceProvider');

        // register an alias
        $this->app->booting(function()
        {
            $loader = \Illuminate\Foundation\AliasLoader::getInstance();
            $loader->alias('Debugbar', 'Barryvdh\Debugbar\Facade');
        });
    }

}

来源

于 2015-07-29T07:50:34.030 回答