How to install dependencies through Composer, but ignoring require-dev?

1

Here at the company where we work we use git for versioning the application. All of them use Composer to install dependencies.

Because it is the most correct approach, removing the vendor generated by the Composer of the repository. That is, when someone does git clone or git pull you must update dependencies via Composer.

But a question arose: When we are developing some dependencies are installed as require-dev . But when we update the system in production, as we use git to do git pull , we also need to run composer update in production.

However, when it is in production, I do not want to include the dependency of development (require-dev).

How can I run composer install or composer update by ignoring the dependencies I've included in require-dev ?

Example:

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "laravelcollective/html": "5.2.*",
    "guzzlehttp/guzzle" : "6.*",
    "maatwebsite/excel": "~2.1.0",
    "phplegends/pt-br-validator" : "2.*"
},
"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.*"
},

Dependency of require-dev can not be installed in production.

    
asked by anonymous 25.05.2016 / 14:52

1 answer

1

According to the documentation link you should use the parameter --no-dev , example of commands:

  • If the composer is global:

    composer install --no-dev
    composer update --no-dev
    
  • If it is not global:

    php composer.phar install --no-dev
    php composer.phar update --no-dev
    

If your server or hosting does not have the SSH or composer option available you can run the commands on your machine and upload the updated project later.

  

Note: If you want to install composer globally I recommend reading this Installing Composer Globally on Linux ?

    
25.05.2016 / 15:00