Laravel - Difference b/w require and require-dev sections in composer.json - Important Interview Question
Normally, Application runs in different environments:
Different Dependencies in Different Environments
The dependencies which are declared in the?require?section of?composer.json?are typically dependencies or packages which are required for running an application in
environments, whereas the dependencies or packages declared in the?require-dev?section are typically dependencies which are required in
environments.
For example, in addition to the packages used for actually running an application, packages might be needed for developing the software, such as:
Deployment
Now, in?development?and?testing?environments, you would typically run
$ composer install
to install both?production?and?development?dependencies.
However, in?staging?and?production?environments, you only want to install dependencies which are required for running the application, and as part of the deployment process, you would typically run
$ composer install --no-dev
to install only?production?dependencies.
In other words, the sections
indicate to?composer?which packages should be installed when you run
$ composer install
or
$ composer install --no-dev
Thanks!
Sr. Software Engineer | PHP | Laravel | MySQL | Docker | AWS
2 年Thanks for sharing.