Challenge - 5 Problems
Composer Setup Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the output of this Composer command?
You run the command
composer --version in your terminal after installing Composer. What output do you expect?PHP
composer --version
Attempts:
2 left
💡 Hint
Composer installation adds the composer command globally if installed correctly.
✗ Incorrect
The
composer --version command outputs the installed Composer version if Composer is installed and accessible in your system PATH.🧠 Conceptual
intermediate1:00remaining
Which file does Composer use to manage dependencies?
After installing Composer, which file should you create or edit to specify your PHP project dependencies?
Attempts:
2 left
💡 Hint
This file is a JSON file that lists your project requirements.
✗ Incorrect
Composer uses
composer.json to define project dependencies and settings. The composer.lock file is generated automatically to lock versions.🔧 Debug
advanced2:00remaining
Why does this Composer install command fail?
You run
composer install but get the error: Could not open input file: composer.phar. What is the most likely cause?PHP
composer install
Attempts:
2 left
💡 Hint
Composer can be installed globally or as a local .phar file.
✗ Incorrect
The error means the system tried to run
php composer.phar but the file composer.phar was not found. This happens if Composer is not installed globally and you are not in the directory with composer.phar.📝 Syntax
advanced2:30remaining
Which command correctly installs Composer globally on Linux?
Choose the correct sequence of commands to install Composer globally on a Linux system.
Attempts:
2 left
💡 Hint
The official recommended method downloads the installer script first.
✗ Incorrect
Option B downloads the installer script, runs it to create composer.phar, then moves it to a global location. Option B moves composer.phar with sudo and to /usr/local/bin which is correct. Option B downloads composer.phar directly but misses installer verification. Option B assumes composer.phar exists and runs install incorrectly.
🚀 Application
expert2:00remaining
After installing Composer, how do you autoload classes in your PHP project?
You have installed dependencies with Composer. Which PHP code snippet correctly includes the Composer autoloader to use installed packages?
Attempts:
2 left
💡 Hint
Composer generates an autoload file inside the vendor directory.
✗ Incorrect
Composer creates
vendor/autoload.php which you include in your PHP scripts to load all dependencies automatically.