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

Asked

Viewed 2,494 times

2

Here in the company where I work we use the git for versioning the application. They all use Composer to install dependencies.

Because it is the most correct approach, removing the vendor generated by Composer of the repository. That is, when someone git clone or the git pull should 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, how do we use git to do the git pull, we also need to rotate the composer update in production.

However, when it is in production, I don’t want it to be included the development dependency (require-dev).

How can I rotate the composer install or composer update 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.*"
},

Dependence on require-dev cannot be installed in production.

1 answer

2


According to the documentation https://getcomposer.org/doc/03-cli.md the parameter must be used --no-dev, example of commands:

  • If the Composer is global:

    composer install --no-dev
    composer update --no-dev
    
  • If it’s 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 read this How to install Composer globally on linux?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.