How To Add Laravel Directory To Your PATH file

Installing Laravel is a simple setup, but it seems like a lot of simple things also go wrong and if you don’t know how to handle them it can get quite difficult to figure out what is the cause and how to fix it. One of the most common errors you are going to come across is “Laravel: command not found”. There is no need to worry! This error is common even if you have installed everything correctly. Nothing is actually wrong just a small quick fix.

On the official tutorial for Laravel, you will come across the following message that throws quite a few people off.
“Make sure to place the ~/.composer/vendor/bin directory in your PATH so the Laravel executable is found when you run the Laravel command in your terminal.” This means place the location of Laravel to your PATH file so that you can use the Laravel command. If you don’t do this you will see the following when you run a Laravel command.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Laravel --version
-bash: Laravel: command not found
Laravel --version -bash: Laravel: command not found
Laravel --version
-bash: Laravel: command not found

I’m going to assume that you have used composer to install Laravel. If not then you will need to update the path below to the location of Laravel on your system. Everything else will remain the same. So the issue here is that the PATH file does not know where Laravel is installed. All you have to do is update PATH so that it knows where Laravel is.

I’m going to break this down a bit just in case you haven’t used composer to install Laravel. $PATH: contains the current contents of the PATH file. This is required so you don’t overwrite the current contents of the PATH. The content after PATH is the location of Laravel. If you use composer it is most likely installed in your users directory. e.g. “/root/.composer/vendor/bin”. You can change the directory to whatever directory you have Laravel installed to. The code below should work if you installed Laravel with composer.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
export PATH="$PATH:~/.composer/vendor/bin"
export PATH="$PATH:~/.composer/vendor/bin"
export PATH="$PATH:~/.composer/vendor/bin"

You should now be able to use Laravel commands regardless of your working directory. To test if this is working, retry the following command.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Laravel --version
Laravel Installer version 1.1
Laravel --version Laravel Installer version 1.1
Laravel --version
Laravel Installer version 1.1

Related Articles

Related Questions

Best GPU for Ultralwide Gaming on a Budget?

I'm looking to game on an ultrawide monitor with high to ultra settings, but I want to keep the costs reasonable. Can anyone suggest...

Has anyone encountered unexpected text in the ChatGPT input box?

So, I recently had a strange encounter while using ChatGPT. Earlier today, I asked it about which came first between Teams, Zoom, and Meets....

Feeling Overwhelmed at Work – Need Some Advice!

I'm really feeling overwhelmed right now with my job at a medium-sized MSP/MSSP where I've worked for two years. I've gone from being the...

4 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

Online Hash Generator – String to Hash Converter

Need to quickly generate a hash from a string? Whether you're verifying file integrity, securing data, or just experimenting with cryptographic tools, this simple...

Convert CSV To HTML Table

Need to quickly turn CSV data into an HTML table? Whether you're copying data from Excel, Google Sheets, or another spreadsheet, this tool makes...

Student Group Randomizer

Creating fair and balanced groups in the classroom can be time-consuming — especially when you're trying to avoid repetition, manage different skill levels, or...

Random Group Generator

Need to split a list of people, items, or ideas into random groups? Our free Random Group Generator makes it quick and easy. Whether...

Flip Text Upside Down – Free Online Tool

Ever wanted to flip your text upside down just for fun or to grab someone’s attention in a creative way? This free online Upside...

Raffle Ticket Generator

If you're running a fundraiser, charity draw, or local event and need raffle tickets fast, this free online tool lets you generate and print...

Latest Posts

Latest Questions