Skip to content

Public beta — free forever, no account required Download now →

Guide

“composer is not recognized” on Windows: fix PATH for PHP and Composer

“'composer' is not recognized as an internal or external command, operable program or batch file.” PowerShell says it as “The term 'composer' is not recognized as the name of a cmdlet”. Both mean the same thing: none of the folders listed in your PATH contains a `composer` or `php` program. Composer runs on PHP, so the PHP folder has to be on PATH too. Here is how to check what Windows can find, add the right folders, and make sure the right PHP wins.

Platform
Windows 10/11
Time
About 10 minutes
You need
  • PHP and Composer downloaded or installed somewhere on the computer
  • Permission to edit your own environment variables (no administrator needed for the user PATH)

Commands checked on Windows 10/11; EnvKit details checked against 0.33.0-beta.56 on 2026-10-29.

  1. Step 1: Check what Windows can find

    where prints every match on PATH in order; the first one is what runs. In PowerShell type where.exe, because plain where there is a different command. If php is found and composer is not, only Composer’s folder is missing. If neither is found, start with PHP.

    Command Prompt or PowerShell
    where.exe php
    where.exe composer
    php -v
    composer -V
  2. Step 2: Know how PATH is read

    Windows builds PATH from two lists: the system PATH (all users) first, then your user PATH. A terminal reads PATH once, when it opens. After any change, open a new terminal. In VS Code or PhpStorm, close the editor completely and reopen it, because its built-in terminals inherit the PATH the editor started with.

  3. Step 3: Add the PHP folder

    Find the folder that contains php.exe (for example C:\php or C:\xampp\php). Open Start, search for “Edit environment variables for your account”, select Path under your user variables, click Edit, then New, and paste the folder. Click OK in both dialogs and open a new terminal.

    Avoid setx PATH "%PATH%;C:\php": setx cuts values longer than 1024 characters and copies the system entries into your user PATH. The PowerShell line below appends to the user PATH safely.

    PowerShell
    $user = [Environment]::GetEnvironmentVariable('Path', 'User')
    [Environment]::SetEnvironmentVariable('Path', "$user;C:\php", 'User')
  4. Step 4: Add Composer

    Composer-Setup.exe adds its own folder to PATH (by default C:\ProgramData\ComposerSetup\bin, which holds composer.bat). If you installed it and it still is not found, check that the folder is in Path and open a new terminal.

    If you downloaded composer.phar by hand, put it in a folder that is on PATH (the PHP folder works) and create composer.bat next to it with the line below, as Composer’s own docs describe.

    composer.bat
    @php "%~dp0composer.phar" %*
  5. Step 5: Make global tools work too

    Tools installed with composer global require, such as the Laravel installer, live in Composer’s global bin folder, usually %APPDATA%\Composer\vendor\bin. If laravel is not recognized, add that folder to PATH the same way. This prints the exact path:

    Command Prompt or PowerShell
    composer global config bin-dir --absolute
  6. Step 6: Make sure the right PHP runs first

    If where.exe php lists several folders, the first one wins, and every system PATH entry comes before every user PATH entry. An old C:\xampp\php in the system PATH beats the PHP you added for your account. Remove the old entry or move yours above it, then check with php -v. php --ini shows which php.ini that PHP loads.

  7. Step 7: Or let EnvKit manage PHP and Composer

    EnvKit is a free app that installs PHP (7.4 to 8.5), Composer, a web server and databases on Windows, each version in its own folder.

    Or install from the terminal
    irm https://envkit.net/install.ps1?c=guide-composer-not-recognized-windows | iex
  8. Step 8: Put EnvKit’s PHP and Composer on PATH

    EnvKit adds nothing to PATH until you choose to. Install Composer from Tools → Composer, then open Tools → Environment (PATH), tick PHP, PHP version + ini launchers (php, php82, php83…) and Composer, and click Save selection. Open a new terminal; php -v and composer -V now use EnvKit’s default PHP, and php84-style commands call a specific version.

    It writes your user PATH by default. When it syncs, it removes Laragon, XAMPP and WampServer folders from the PATH it writes. An old PHP in the system PATH still comes first; remove it there, or turn on Write to system PATH (all users), which needs administrator rights.

If something goes wrong

It works in a new Command Prompt but not in VS Code
VS Code still has the old PATH. Close every VS Code window and open it again; a new terminal tab inside the running editor is not enough.
“The system cannot find the path specified” when running composer
composer.bat calls php, and that PHP folder is missing from PATH or moved. Fix the PHP entry first, then run composer -V again.
Composer runs on the wrong PHP version
Composer uses whichever php comes first on PATH. Run where.exe php, move the version you want to the top, or call it directly: C:\php84\php.exe C:\ProgramData\ComposerSetup\bin\composer.phar install.