This section contains notes and hints specific to getting PHP running from the command line for Windows. Show
Getting PHP to run from the command line can be performed without making any changes to Windows. C:\php\php.exe -f "C:\PHP Scripts\script.php" -- -arg1 -arg2 -arg3 But there are some easy steps that can be followed to make this simpler. Some of these steps should already have been taken, but are repeated here to be able to provide a complete step-by-step sequence.
Following these steps will allow PHP scripts to be run from any directory without the need to type the PHP executable or the The example below details some of the registry changes that can be made manually. Example #1 Registry changes Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.php] @="phpfile" "Content Type"="application/php" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\phpfile] @="PHP Script" "EditFlags"=dword:00000000 "BrowserFlags"=dword:00000008 "AlwaysShowExt"="" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\phpfile\DefaultIcon] @="C:\\php\\php-win.exe,0" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\phpfile\shell] @="Open" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\phpfile\shell\Open] @="&Open" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\phpfile\shell\Open\command] @="\"C:\\php\\php.exe\" -f \"%1\" -- %~2" With these changes the same command can be written as: "C:\PHP Scripts\script" -arg1 -arg2 -arg3or, if your ftype phpfile="C:\php\php.exe" -f "%1" -- %~24 path is in the PATH environment variable:
|