Dev and prod dependencies
Composer splits dependencies into two types: dev
and prod
.
The concept here is quite simple – prod dependencies are those that are needed for your application to run. This might include emailing, logging, framework components, and so on. This is the default when requiring new dependencies.
The other dependency type is dev and is used when we want to bring in tooling that assists with development. There are all kinds of development tools in the PHP ecosystem to power things, such as unit testing, static analysis, coding standards, and more. When we install these kinds of tools, they can often bring in large numbers of their own dependencies as well, creating a very large PHP code base.
Requiring dev dependencies
When we require a new dependency that we want to be a dev
dependency, we can simply add a --dev
flag to the command; for example:
composer require phpunit/phpunit --dev
This command will update the composer.json
file and add...