Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if Composer is installed by displaying its version.
PHP
composer [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'install' instead of '--version' will try to install packages.
Using 'update' changes packages, not shows version.
✗ Incorrect
The composer --version command displays the installed Composer version.
2fill in blank
mediumComplete the command to install Composer globally on your system.
PHP
php -r "copy('https://getcomposer.org/installer', '[1]');"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'composer.phar' downloads the binary, not the installer script.
Using 'install.php' or 'setup.php' are incorrect file names.
✗ Incorrect
The installer script is saved as composer-setup.php before running it.
3fill in blank
hardFix the error in the command to move Composer to a global location.
PHP
mv [1] /usr/local/bin/composer Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to move the installer script instead of the binary.
Using a wrong file name like 'composer.phar.php'.
✗ Incorrect
After running the installer, the Composer binary is named composer.phar and should be moved.
4fill in blank
hardFill both blanks to create a new PHP project with Composer and install a package.
PHP
composer [1] && composer [2] monolog/monolog
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'install' instead of 'init' to start a project.
Using 'update' instead of 'require' to add packages.
✗ Incorrect
composer init creates a new project, and composer require adds a package.
5fill in blank
hardFill all three blanks to update Composer and check its version.
PHP
composer [1] && php [2] --version
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'update' instead of 'self-update' to update Composer.
Not specifying the Composer binary file when running with PHP.
✗ Incorrect
composer self-update updates Composer, then php composer.phar --version checks version.