首页 > 解决方案 > When I run composer on Windows, I get an error of 'php.exe' is not recognized as an internal or external command, operable program or batch file.'

问题描述

I have an install of Acquia Dev Desktop 2 for local Drupal development, which comes with PHP and some tools like composer and drush. However, when I run composer, it gives me the error:

'php.exe' is not recognized as an internal or external command,
operable program or batch file.

I have already seen many other similar questions on here, which universally say that php needs to be added to the PATH. However, I have already done this adding:

C:\Program Files (x86)\DevDesktop\php7_3_x64
C:\Program Files (x86)\DevDesktop\tools //contains Composer and Drush

This results in me being able to run php and php.exe from Git Bash fine, but if I try composer the aforementioned error still crops up. It's not working on Powershell, cmd or git bash for windows, but I am in particular trying to get it to work on Git Bash so here is my .bashrc. I've tried lots of other variations, but to no avail.

alias php='php.exe'
alias php.exe=\'C:/Program\ Files\ \(x86\)\\DevDesktop\\php7_3_x64\\php.exe\'
alias drush='drush.bat'
alias composer='composer.bat'

I'm at a loss on what steps to take, so any insight would be greatly appreciated!

标签: phpwindowscomposer-phpgit-bash

解决方案


D'oh,需要重新启动我的计算机。非常感谢李健!


推荐阅读