Recall & Review
beginner
What does the
composer require command do?It adds a new package to your project and updates the
composer.json and composer.lock files automatically.Click to reveal answer
beginner
What is the purpose of the
composer.lock file?It locks the exact versions of all installed packages to ensure consistent installs across different environments.
Click to reveal answer
intermediate
How does Composer handle version conflicts between packages?
Composer tries to find a set of package versions that satisfy all version constraints. If it can't, it shows an error and stops the installation.
Click to reveal answer
beginner
What is the difference between
require and require-dev in Composer?require is for packages needed in production, while require-dev is for packages only needed during development, like testing tools.Click to reveal answer
beginner
Why should you commit
composer.lock to version control?Committing
composer.lock ensures everyone uses the same package versions, avoiding unexpected bugs caused by different dependencies.Click to reveal answer
What happens when you run
composer require monolog/monolog?✗ Incorrect
The
composer require command adds the package and updates both composer.json and composer.lock.Which file ensures consistent package versions across different machines?
✗ Incorrect
composer.lock locks the exact versions of installed packages.If two packages require conflicting versions of the same dependency, what does Composer do?
✗ Incorrect
Composer stops and shows an error if it cannot resolve version conflicts.
Which command installs packages listed in
require-dev?✗ Incorrect
Running
composer install installs both require and require-dev packages by default.Why is it important to commit
composer.lock to your project repository?✗ Incorrect
Committing
composer.lock ensures consistent dependency versions for all developers.Explain how
composer require helps manage dependencies in a PHP project.Think about what files change and what happens to the package.
You got /4 concepts.
Describe the role of
composer.lock and why it is important to commit it to version control.Consider what happens if different developers have different versions.
You got /4 concepts.