Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

angelorigo's avatar

Laravel not found after running composer global require laravel/installer

Hi, i am on Ubuntu 24 and try to install the laravel installer with : composer global require laravel/installer after that i try to run laravel new my-application command but the message was: laravel: command not found.

Is there any aditional steps ?

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

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:

  1. Locate the Composer global bin directory: By default, Composer stores global binaries in a directory like ~/.composer/vendor/bin or ~/.config/composer/vendor/bin depending on your Composer version and configuration.

  2. 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 laravel command from anywhere.

  3. 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

  1. Find the Composer global bin directory: Run the following command to find the Composer global bin directory:

    composer global config bin-dir --absolute
    

    This will output the path to the global bin directory, for example:

    /home/your-username/.composer/vendor/bin
    
  2. 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 ~/.bashrc
    

    If you are using Zsh, you would edit ~/.zshrc:

    nano ~/.zshrc
    
  3. Update the PATH: Add the following line to the end of the file, replacing /home/your-username/.composer/vendor/bin with the path you found in step 1:

    export PATH="$PATH:/home/your-username/.composer/vendor/bin"
    
  4. Apply the changes: After saving the file, apply the changes by running:

    source ~/.bashrc
    

    or for Zsh:

    source ~/.zshrc
    
  5. Verify the installation: Now, you should be able to run the laravel command:

    laravel new my-application
    

Example

Here is an example of what the steps might look like in practice:

  1. Find the Composer global bin directory:

    composer global config bin-dir --absolute
    # Output: /home/your-username/.composer/vendor/bin
    
  2. Edit the shell configuration file:

    nano ~/.bashrc
    
  3. Add the directory to the PATH:

    export PATH="$PATH:/home/your-username/.composer/vendor/bin"
    
  4. Apply the changes:

    source ~/.bashrc
    
  5. Verify the installation:

    laravel new my-application
    

By following these steps, you should be able to run the laravel command without any issues.

7 likes

Please or to participate in this conversation.