Certainly! The issue you're encountering is likely due to the global Composer bin directory not being added to your system's PATH. Here are the steps to resolve this:
-
Locate the Composer global bin directory: By default, Composer stores global binaries in a directory like
~/.composer/vendor/binor~/.config/composer/vendor/bindepending on your Composer version and configuration. -
Add the Composer global bin directory to your PATH: You need to add this directory to your system's PATH so that you can run the
laravelcommand from anywhere. -
Update your shell configuration file: Depending on the shell you are using (e.g., Bash, Zsh), you will need to update the appropriate configuration file (
.bashrc,.zshrc, etc.).
Here are the detailed steps:
Step-by-Step Solution
-
Find the Composer global bin directory: Run the following command to find the Composer global bin directory:
composer global config bin-dir --absoluteThis will output the path to the global bin directory, for example:
/home/your-username/.composer/vendor/bin -
Add the directory to your PATH: Open your shell configuration file in a text editor. For example, if you are using Bash, you would edit
~/.bashrc:nano ~/.bashrcIf you are using Zsh, you would edit
~/.zshrc:nano ~/.zshrc -
Update the PATH: Add the following line to the end of the file, replacing
/home/your-username/.composer/vendor/binwith the path you found in step 1:export PATH="$PATH:/home/your-username/.composer/vendor/bin" -
Apply the changes: After saving the file, apply the changes by running:
source ~/.bashrcor for Zsh:
source ~/.zshrc -
Verify the installation: Now, you should be able to run the
laravelcommand:laravel new my-application
Example
Here is an example of what the steps might look like in practice:
-
Find the Composer global bin directory:
composer global config bin-dir --absolute # Output: /home/your-username/.composer/vendor/bin -
Edit the shell configuration file:
nano ~/.bashrc -
Add the directory to the PATH:
export PATH="$PATH:/home/your-username/.composer/vendor/bin" -
Apply the changes:
source ~/.bashrc -
Verify the installation:
laravel new my-application
By following these steps, you should be able to run the laravel command without any issues.