'composer' is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
4 min

banner

# 'composer' is not recognized as an internal or external command

The error "'composer' is not recognized as an internal or external command, operable program or batch file" occurs for 2 main reasons:

  1. Not having Composer installed on your machine.
  2. Not having the path to the composer executable in your system's PATH environment variable.

composer is not recognized as internal or external command

If you already have Composer installed and know where the executable is located, scroll down to the next subheading.

To install and configure Composer on Windows:

  1. Visit the official Composer downloads page and click on the "Composer-Setup.exe" link.

download composer setup exe

  1. When you start the installer, you might have to change your app recommendation settings.

change my app recommendation settings

  1. You can set the "Choose where to get apps" value to "Anywhere, but warn me before installing an app that's not from the Microsoft Store".

choose where to get apps

  1. Click on "Install anyway".

click install anyway

  1. Click on "Install for all users".

install for all users

  1. On the next screen, click "Next" without checking the checkbox.

click next without checking checkbox

  1. The Composer installer should be able to find where php is installed on your machine.

composer finds php location

  1. Don't enter any proxy settings and click "Next".

dont enter proxy settings

  1. Click on the "Install" button to install Composer.

composer click install

  1. Click on the "Next" button.

close command prompt

Note that you must restart your Command prompt shell for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

click finish button

In a new Command Prompt, issue the composer -V command to verify the composer executable is available.

cmd
composer -V composer

composer command works

If you still get the "'composer' is not recognized as an internal or external command, operable program or batch file" error, we have to add the path to the composer executable to your system's PATH environment variable.

The path to the composer executable on my machine is the following.

cmd
C:\ProgramData\ComposerSetup\bin

path to composer executable

We are looking for the directory that contains the composer.bat file.

# Add the path to the composer executable to your system's PATH environment variable

To add the path to the composer executable in your system's PATH environment variable:

  1. Click on the Search bar and type "environment variables".
  2. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "System variables" section, select the "Path" variable and click "Edit".

select path and click edit

  1. You can either click "New" and then "Browse" and navigate to the path or paste it directly.

click new browse

The path on my machine is the following.

cmd
C:\ProgramData\ComposerSetup\bin

path to composer executable

We are looking for the directory that contains the composer.bat file.

  1. Once you find the path to your composer executable file, add it and click on the "OK" button twice.

added path to composer executable

  1. Close your Command prompt application and then reopen it.
Note that you must restart your Command prompt shell for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

Open a new Command Prompt and run the composer -V command to make sure the composer executable is accessible.

cmd
composer -V composer

composer command works

If you still get the error, you have to add the .PHAR extension to your PATHEXT system environment variable.

  1. Click on the Search bar and type "environment variables".
  2. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "System variables" section, select the "PATHEXT" variable and click "Edit".

edit pathext

  1. Add ;.PHAR to the end of the value of the environment variable.

add phar extension

  1. Once you add ;.PHAR to the end of the PATHEXT system environment variable, click on "OK" twice to confirm.

  2. Close your Command prompt application and then reopen it.

Note that you must restart your Command prompt shell for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

Open a new Command Prompt and run the composer -V command to make sure the composer executable is accessible.

cmd
composer -V composer

composer command works

If the error persists, try restarting your PC to make sure you don't have any stale CMD, PowerShell or IDE sessions and rerun the composer -V command.

# Conclusion

To solve the "'composer' is not recognized as an internal or external command, operable program or batch file" error, make sure:

  1. You have Composer installed on your machine.
  2. You have the path to the composer executable in your system's PATH environment variable.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.