Composer is not recognized as an internal or external command

Composer is not recognized as an internal or external command

Composer is not recognized as an internal or external command operable program or batch file error can occur due to two reasons, Composer is not installed properly or the Composer executable file is not found in the environment variables as a result of Windows, linux and mac Command Prompt. In this tutorial, we will show two solutions to fix this error in Windows, Linux, and Mac systems.

To fix this error, you can use following solutions:

  • Solution 1: Add composer executable path to system’s PATH environment variable
  • Solution 2: Uninstall and Reinstall Composer

Solution 1: Add composer executable path to system’s PATH environment variable

If you have installed the composer in your system. Now, you need to add Composer to the PATH environment variables, you can do the following:

  • Step 1: Verify PHP Installation
  • Step 2: Verify Composer Installation
  • Step 3: Add Composer to System PATH

Step 1: Verify PHP Installation

Firstly, open a command prompt or terminal and run the following command into it to ensure PHP is correctly installed and in your system’s PATH:

php -v

Step 2: Verify Composer Installation

Once you have verified php installation, then you need to run the following command to check if Composer is correctly installed and accessible:

composer --version

If you still encounter the “composer is not recognized” error, proceed with the following steps to add Composer to your PATH in linux, windows or mac system.

Step 3: Add Composer to System PATH

If you are using Windows system, To add the composer executable path to the system PATH environment variable, you can do the following:

  1. Search for “Environment Variables” in your Windows search bar and select “Edit the system environment variables.”
  2. In the “System Properties” window, click the “Environment Variables” button.
  3. Under “System variables,” scroll down and find the “Path” variable. Select it and click “Edit.”
  4. In the “Edit Environment Variable” window, click “New” and add the path to your Composer installation. This is typically C:\ProgramData\ComposerSetup\bin, but it may vary depending on your installation location.
  5. Click “OK” to close all the windows.
  6. Open a new command prompt or terminal and run composer --version again. You should now see Composer’s version information without the error.

If you are using linux or mac system, To add the composer executable path to the system PATH environment variable, you can do the following:

  1. Open a terminal window.
  2. Edit your shell’s profile configuration file (e.g., ~/.bashrc, ~/.zshrc, or ~/.profile) using a text editor. For example:
    • nano ~/.bashrc
  3. Add the following line at the end of the file, replacing /path/to/composer with the actual path to your Composer executable:
    • export PATH=”$PATH:/path/to/composer”
  4. Save and close the file.
  5. Run the following command to apply the changes to your current session:
    • source ~/.bashrc
  6. Open a new terminal window and run composer --version again. You should now see Composer’s version information without the error.

Solution 2: Uninstall and Reinstall Composer

If you still found that Composer is not recognized as an internal or external command operable program or batch file. So you uninstall composer from system and also download it from the official website and install composer again.

Conclusion

That’s it, you should have resolved the “composer is not recognized as an internal or external command” error by using this tutorial. Composer should now be accessible from the command line, allowing you to manage your PHP dependencies seamlessly.

Recommended Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *