What is Composer in PHP?
Why Interviewers Ask This
This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex PHP topics. It also reveals how well you can explain technical ideas to non-experts.
Answer
Composer is PHP's standard dependency manager. It allows you to declare the libraries your project depends on and manages installing and updating them. Create a composer.json file specifying dependencies: { "require": { "vendor/package": "^2.0" } }. Run composer install to download dependencies to the vendor/ folder. Composer also provides autoloading — just include vendor/autoload.php and all installed packages and your own classes (configured in the autoload section) are available without manual require statements. It uses the composer.lock file to lock dependency versions for reproducible builds. Packagist (packagist.org) is the main repository for Composer packages.
Common Mistake
Many candidates answer correctly but can't explain the 'why'. Always be prepared to justify your answer with a concrete example or use case from your PHP experience.