zsh: command not found: composer

command-not-found

Updated August 29, 2026

When zsh cannot find composer, either Composer is not installed or its executable directory is missing from PATH.

command -v composer
php --version
printf '%s\n' "$PATH"

Composer's official installer can create composer.phar in the current directory. Run it explicitly with php composer.phar, or move it to a directory already in your path according to Composer's installation guide. If you installed it globally in /usr/local/bin or another directory, start a new shell after changing PATH:

source ~/.zshrc
composer --version

A project can also use a local composer.phar; that is different from a global Composer installation. Check the project's README before installing a second copy. If composer works as your user but not with sudo, do not use sudo composer as a path fix: sudo may intentionally use a different PATH and running dependency management as root can create files your user cannot edit.

Sources

related.

Ruslan Osipov

Ruslan Osipov

About the author