What is the difference between require and require-dev sections in composer.json?

前端 未结 6 496
北海茫月
北海茫月 2020-11-28 20:38

I\'m beginning using composer, I know so little about it and have a little experience with web application development.

I just walk through Nettuts+ Tutorial, so I h

6条回答
  •  醉梦人生
    2020-11-28 21:01

    General rule is that you want packages from require-dev section only in development (dev) environments, for example local environment.

    Packages in require-dev section are packages which help you debug app, run tests etc.

    At staging and production environment you probably want only packages from require section.

    But anyway you can run composer install --no-dev and composer update --no-dev on any environment, command will install only packages from required section not from require-dev, but probably you want to run this only at staging and production environments not on local.

    Theoretically you can put all packages in require section and nothing will happened, but you don't want developing packages at production environment because of the following reasons :

    1. speed
    2. potential of expose some debuging info
    3. etc

    Some good candidates for require-dev are :

    "filp/whoops": "^2.0",
    "fzaninotto/faker": "^1.4",
    "mockery/mockery": "^1.0",
    "nunomaduro/collision": "^2.0",
    "phpunit/phpunit": "^7.0"
    

    you can see what above packages are doing and you will see why you don't need them on production.

    See more here : https://getcomposer.org/doc/04-schema.md

提交回复
热议问题