mtpultz
mtpultz

Reputation: 18298

Laravel Forge Deployment Script Fails on Debugbar Provider when using Composer Install --no-dev

When I try to deploy using Forge using this deployment script:

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

It fails and throws the error below. I'm using these dependencies in composer.json, and have no dev dependencies inside require.

Composer.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"
},

Error

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

How do I fix this so deployments don't pull in development dependencies, but not have to change the providers setup for development? Or, should I just not bother setting --no-dev and pull in everything? Works when I drop --no-dev flag.

Upvotes: 1

Views: 656

Answers (1)

KristofM
KristofM

Reputation: 350

I use DebugBar myself too and just pull in everything with composer. I only show the debugbar on my development machine with:

// 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');
        });
    }

}

Source

Upvotes: 2

Related Questions