php.exe from CLI

Associate
Joined
2 Oct 2003
Posts
2,121
Location
Chester
Having previously enjoyed calling 'php' on Linux systems from bash, I want to know if it is possible to called 'php'.exe in the command prompt on Windows? ie type p + h + TAB to autocomplete to php.

Got a feeling its going to be an environmental path or something, cant put my finger on it though!
 
Once the Registry Editor is up and running, navigate to following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

Once you open the App Paths key, you’ll see a whole set of subkeys, each titled after an executable file. Now, as you look through the list of existing Run Command Shortcuts, you’ll see several subkeys named after native Windows apps, such as Wordpad.exe (WordPad) and Iexplore.exe (Internet Explorer). The reason that some of the Windows native apps appear in the App Paths key is that their executable files are located in folders other than Windows or System32. For example, WordPad is located in the Program Files\Accessories folder, and Internet Explorer is located in the Program Files\Internet Explorer folder.

To create a Run Command Shortcut for your favorite application, right-click on the App Paths key and select the New | Key command. When you see the new key appear, give it a two to eight character name—something that’s mnemonic or easy to associate with the application—along with an .exe extension.

Once you create the new key, you’ll see an empty String value labeled Default in the key. Double-click the Default value and when you see the Edit String dialog box, type the full path to the application’s executable file in the Value Data text box press OK to save.

Then using the run command just type php.exe and it should work.
 
Also press your Windows key + R to quickly get the run command up then just type php.exe when its done. Should work let me know if not.
 
Also press your Windows key + R to quickly get the run command up then just type php.exe when its done. Should work let me know if not.

Getting so close to a solution and thank you for your help so far. I want to call php from cmd.exe not the run dialog. I've added it to the registry and it didn't work :(
 
Hmm have to cook dinner - if no one else has solved it for you I'll rethink a solution and let you know how to call it from the cmd executable.
 
Could suggest a batch file to open it unless you are adament (sp?) on using cmd.exe to open it. If a batch file is good enough then an example is.

open notepad type

cd "c:\Program Files\Ahead\Nero"
nero.exe

save as *.bat file
This will open the program from the batch file

So that it works from anywhere on your PC, correctly it should be:

c:
cd \
cd "Program Files\Ahead\Nero"
nero.exe
 
just right click "My Computer" > properties > Advanced > Environment Variables > Path

Then append the path of the php.exe's *directory* (not full path to the .exe) using the path separator (I think it's semi-colon on windows.)

YMMV if using vista.
 
Back
Top Bottom