Troubleshooting
Composer installs a global package but cannot find its command
Many Composer packages include CLI binaries or executables that give you access to features from the command line.
The Laravel installer, for example, provides the laravel command. Creating a project may also require other programs depending on the options you choose.
The first step is to install the package globally in your account with composer global require:
composer global require "laravel/installer"
If running laravel makes the terminal reply command not found, first check that the installation finished correctly and that the package contains the binary:
composer global show laravel/installer
composer global config bin-dir --absolute
The second command returns the real binaries directory. Check that laravel exists there and run command -v laravel to find out whether the shell already finds it.
Only if the binary exists and its directory is not in PATH, add the path Composer returned to the shell's startup file. In Bash, for example:
export PATH="$PATH:/ruta/devuelta/por/composer"
Run source ~/.bashrc to apply the change if the session uses Bash. In another shell, edit its corresponding startup file.
Do not assume the path is always ~/.composer/vendor/bin: it can change depending on COMPOSER_HOME, XDG or Composer's bin-dir option.
If it finds the command but fails
First run laravel --version to confirm which binary you are using without creating a project. A permissions, PHP interpreter or requirements error is different from command not found and is not fixed by adding the directory to PATH again.
A cron job or a non-interactive session may not read ~/.bashrc. For those tasks, use verified absolute paths and the compatible PHP. Adding the directory at the end of PATH keeps the priority of an existing command with the same name; use command -v to detect that case before changing the order. Do not add directories that other users can write to.
You may also find useful
- Memory limit errors in Composer and PHP Confirm the PHP limit Composer uses, apply a correct temporary increase and tell memory_limit apart...
- "An error occurred while sending the message" in the PrestaShop contact form Diagnose the contact form rejection and fix an old override only when it does not send contactform's...
- 404 errors on static files slow down browsing Detect missing static resources that trigger PHP and use CPU, serve them as lightweight 404s and gui...
- Debug errors in PHP applications or files Diagnose a blank screen or a 500 error by reproducing the failure and checking the most specific log...
Something wrong or out of date? Tell us and we will review it.