Junior — Middle
How to add a dev dependency in the require section of your composer.json file?
sobes.tech AI
Answer from AI
In the composer.json file, development dependencies (dev dependencies) are added to the require-dev section. This allows you to separate libraries needed only for development and testing from those required in production.
Example of adding a dev dependency:
{
"require-dev": {
"phpunit/phpunit": "^9.5"
}
}
To add a dependency via the command line, you can use:
composer require --dev phpunit/phpunit
This will automatically add the package to the require-dev section of your composer.json.