Fix “laravel: command not found” on macOS (zsh and bash)

Fix “laravel: command not found” on macOS (zsh and bash)
Quick answer

Install the installer first with composer global require laravel/installer, then ask Composer where it puts its executables: composer global config bin-dir --absolute. Add that path to your PATH in ~/.zshrc, then run source ~/.zshrc. On macOS with bash, the file is ~/.bash_profile, never ~/.bashrc.

You type laravel new my-project and the terminal answers:

code
zsh: command not found: laravel

The problem is almost never Laravel. It is that the executable installed by Composer sits in a folder your shell never looks at. So you need to find that folder, then add it to your PATH.

Part of the Web development reading path. Procedure verified on 2 September 2026 on macOS 26.5.1 with Composer 2.9.5 and zsh.

First: is the installer actually installed?

The laravel command does not ship with Composer, it is installed separately:

bash
composer global require laravel/installer

If you have never run that, no amount of PATH tweaking will make the command appear. And you can happily do without it: composer create-project laravel/laravel my-project does the same job with no global installer.

Finding the right folder instead of guessing it

Most tutorials have you copy $HOME/.composer/vendor/bin. That is often right, but not always: Composer picks its home folder according to the system and to the environment variables it finds. Rather than betting on it, ask it:

bash
composer global config bin-dir --absolute
code
/Users/gekkode/.composer/vendor/bin

That is the result on macOS 26.5.1. On an installation set up to follow the XDG conventions, the command may return ~/.config/composer/vendor/bin. Always use what the command prints on your machine, not what a tutorial says.

The folder may not exist yet

As long as no global package is installed, the path is correct but the folder is missing. That causes no trouble at all: adding a non-existent folder to your PATH raises no error, and it will be created by the first composer global require.

Adding the folder to your PATH with zsh

zsh has been the default macOS shell since Catalina. The file to edit is ~/.zshrc:

bash
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Replace the path with the one the previous command returned. The source applies the change to the current session, without it, it only takes effect in a new terminal.

Check it:

bash
which laravel
laravel --version

And if you use bash

On macOS Mojave and earlier, or if you have deliberately stuck with bash, the file is ~/.bash_profile:

bash
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
~/.bashrc is not read at startup on macOS

This is the classic mistake, and the previous version of this article made it. On macOS, Terminal opens a login shell, which reads ~/.bash_profile and not ~/.bashrc. A line added to ~/.bashrc will never be applied, which makes it look as though the whole thing does not work.

To find out which shell you are running:

bash
echo $SHELL
# /bin/zsh  →  ~/.zshrc
# /bin/bash →  ~/.bash_profile

If the command is still not found

Three checks, in order. First, does your PATH really contain the folder:

bash
echo $PATH | tr ':' '\n' | grep composer

Next, is the executable there:

bash
ls "$(composer global config bin-dir --absolute)"

If it is missing, the global install failed. Run it again and read the output: a PHP version conflict is the most common cause.

Finally, if Composer itself cannot be found, it is the same problem one level down. On macOS, the simplest install goes through Homebrew:

bash
brew install composer

On a server the question comes up in rather different terms: see installing Composer on Debian.

The alternative that removes the problem

Laravel Herd installs PHP, Composer and the Laravel installer in a managed environment, and takes care of the PATH itself. For a macOS development machine built from scratch, it is the shortest route: there is no shell configuration file left to touch.

If you already work with a Homebrew installation you know your way around, the PATH approach described above remains perfectly valid.

Common errors

Writing to ~/.bashrc on macOS Terminal opens a login shell, which reads ~/.bash_profile. A line added to ~/.bashrc is never applied.
Copying a path found in a tutorial Composer picks its folder according to the system and the environment variables. Only composer global config bin-dir --absolute gives the right path on your machine.
Forgetting composer global require laravel/installer The laravel command does not come with Composer. Without it, no PATH setting will make it appear.
Changing the PATH without reloading Changes only apply to new sessions, unless you run source on the file you edited.

ComposerLaravelmacOSPHP

Damien Flandrin Web developer since 2010, creator of Gekkode and Email Impact. Every article is tested on a real project before publication. Contact
Newsletter

New tests, tutorials and projects, by e-mail.

Reproducible tests, versioned code, dated results. Never any spam.