At Sreyas IT Solutions, we take pride in our extensive experience with Laravel development. Over the years, we have successfully completed numerous Laravel projects for clients worldwide, ensuring their satisfaction with robust and scalable solutions. Our expertise enables us to address Laravel challenges efficiently, ensuring high-quality results for our clients.
Below, we share a bottleneck we encountered during one of our Laravel projects and how we resolved it using our years of experience and in-depth knowledge of the framework. This guide highlights the issue of the Laravel command not being recognized and the systematic approach to troubleshooting and resolving it.
When the Laravel command is run in the terminal or command prompt and the error appears:
laravel: The term ‘laravel’ is not recognized as the name of a cmdlet, function, script file, or operable program.
This error means the Laravel installer is either not installed or hasn’t been added correctly to the system’s environment variables. Here are the steps to fix this issue.
Verify Composer Global Installation in Laravel Projects
First, check if Composer is installed and working correctly on the system. Laravel projects requires Composer for installation. Use the following command to see if Composer is installed:
composer –version
Install Laravel Installer Globally
The Laravel installer must be installed globally to run the Laravel command from any directory. Use the following command to install it:
composer global require laravel/installer
This command installs the Laravel installer globally, making the Laravel command available in the terminal.
Check if Composer’s Global Bin Path is in the System PATH
After installing the Laravel installer, make sure the directory that holds the global Composer binaries is added to the system’s PATH environment variable.
For Windows:
- By default, Composer installs the global binaries in the folder C:\Users\<Username>\AppData\Roaming\Composer\vendor\bin
- ensure that this path is added to the system’s PATH variable
- To check or add the path:
- Right-click on This PC or Computer and select Properties.
- Select Advanced System Settings.
- In the System Properties window, click on Environment Variables.
- Under System variables, find the Path variable and click Edit.
- Add the path to the Composer bin directory (e.g., C:\Users\<Username>\AppData\Roaming\Composer\vendor\bin)
- Click OK to save the changes.

For macOS/Linux:
- Open terminal and run:
echo $SHELL
- If the output is /bin/bash or similar, edit ~/.bashrc or ~/.bash_profile file.
- If it’s /bin/zsh, edit ~/.zshrc file.
- Add the following line to include the Composer bin directory in the PATH:
export PATH=”$PATH:$HOME/.composer/vendor/bin”
3. After editing the file, run:
source ~/.bashrc # For Bash users
source ~/.zshrc # For Zsh users
Verify Laravel Installer
After adding the correct path to the system’s PATH, close and reopen the terminal (or PowerShell window) and try running the Laravel command again:
laravel –version
This should display the version of the Laravel installer, confirming that it is installed and recognized.
Use Laravel Installer
Once the Laravel installer is installed correctly, a new Laravel project development can be created with the command:
laravel new project-name
This will set up a new Laravel application in a folder named project-name.
Conclusion
Following these steps ensures the Laravel installer is installed correctly, and the global Composer bin directory is added to the system’s PATH. This allows the Laravel command to work without issues. If problems persist, check the Composer and Laravel installer configuration or reinstall them.