This article provides a comprehensive guide to resolving the “laravel command not found” error, a common issue faced by developers after installing the Laravel installer globally using Composer. It outlines the root cause of the problem and offers detailed, platform-specific solutions for macOS, Linux, and Windows, ensuring you can successfully execute Laravel commands from your terminal.

After running:

composer global require laravel/installer

when executing:

laravel

you receive:

-bash: laravel: command not found

Root Cause

The laravel executable is installed in Composer’s global vendor/bin directory (commonly ~/.config/composer/vendor/bin or ~/.composer/vendor/bin), which is not in your PATH. Your shell can’t locate the executable.

Step‑by‑Step: Locate and Add the Directory to PATH

Step 1: Locate the Composer Global Bin Path

composer global config bin-dir --absolute

This outputs something like:

/home/your‑username/.config/composer/vendor/bin

Use this path in the following steps.

For Linux (Ubuntu, Debian, etc.)

1. Edit your shell profile:

If using Bash:

nano ~/.bashrc

If using Zsh:

nano ~/.zshrc

2. Add this line at the bottom:

export PATH="$HOME/.config/composer/vendor/bin:$PATH"

(Replace with your actual path from the previous step.)

3. Save and reload:

source ~/.bashrc

or

source ~/.zshrc

4. Verify:

laravel --version

For macOS

1. Determine your shell:

echo $SHELL
  • If output is /bin/zsh, edit: ~/.zshrc
  • If output is /bin/bash, edit: ~/.bash_profile

2. Open the correct file:

nano ~/.zshrc
(or ~/.bash_profile)

3. Add to the bottom:

export PATH="$HOME/.config/composer/vendor/bin:$PATH"

4. Reload your shell:

source ~/.zshrc
(or source ~/.bash_profile)

5. Test:

laravel --version

For Windows

1. Locate the folder:

C:\Users\YourUsername\AppData\Roaming\Composer\vendor\bin

2. Add to the PATH:

  • Open Environment Variables
  • Find Path under User variables

Click Edit → New, then paste:

C:\Users\YourUsername\AppData\Roaming\Composer\vendor\bin
  • Click OK on all dialogues

3. Restart your terminal, then verify:

laravel --version

Troubleshooting Tips

# Check Composer installation:
composer --version

# Confirm Laravel installer is installed globally:
composer global show laravel/installer

# Verify your PATH:
echo $PATH

# Confirm the directory contains the Laravel executable:
ls $(composer global config bin-dir --absolute)

Optional: No‑Global Install Alternative

If you prefer not to modify your PATH:

npx laravel new project‑name

This will invoke the installer directly without global installation.

References

Laravel

Getcomposer CLI

Need Help With Laravel Development?

Work with our skilled Laravel developers to accelerate your project and boost its performance.

Hire Laravel Developer

Support On Demand!

Related Q&A