“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.
Step 1: Check what Windows can find
whereprints every match on PATH in order; the first one is what runs. In PowerShell typewhere.exe, because plainwherethere is a different command. Ifphpis found andcomposeris 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 -VStep 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.
Step 3: Add the PHP folder
Find the folder that contains
php.exe(for exampleC:\phporC:\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":setxcuts 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')Step 4: Add Composer
Composer-Setup.exe adds its own folder to PATH (by default
C:\ProgramData\ComposerSetup\bin, which holdscomposer.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.pharby hand, put it in a folder that is on PATH (the PHP folder works) and createcomposer.batnext to it with the line below, as Composer’s own docs describe.composer.bat @php "%~dp0composer.phar" %*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. Iflaravelis not recognized, add that folder to PATH the same way. This prints the exact path:Command Prompt or PowerShell composer global config bin-dir --absoluteStep 6: Make sure the right PHP runs first
If
where.exe phplists several folders, the first one wins, and every system PATH entry comes before every user PATH entry. An oldC:\xampp\phpin the system PATH beats the PHP you added for your account. Remove the old entry or move yours above it, then check withphp -v.php --inishows whichphp.inithat PHP loads.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 terminalirm https://envkit.net/install.ps1?c=guide-composer-not-recognized-windows | iexStep 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 -vandcomposer -Vnow use EnvKit’s default PHP, andphp84-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.batcallsphp, and that PHP folder is missing from PATH or moved. Fix the PHP entry first, then runcomposer -Vagain.- Composer runs on the wrong PHP version
- Composer uses whichever
phpcomes first on PATH. Runwhere.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.