To run a php script from the command line follow this procedure:
Simply run the CMD command in windows and type the following command:
:location\to\the\running\>php.exe -f “c:\location\of\php\scriptfolder\myscript.php”
Ensure the local server is up and running – fire you WAMP/ XAMP or whatever bundle you are using.
For WAMP server – the php.exe file is located in C:\wamp\bin\php\php5.3.10.
On Windows if I have a myscript.php in a folder called C:\Wamp\www\Spiders\myscript.php – I can run it from the command line tool like this:
For MAC & Linux users
The method for MAC & Linux would be similar – except for the use of forward slash(/) when specifying path names.
Disclaimer: I have not checked it though on either MAC or Linux Environment.
Specifying the Environment Variable
To avoid typing the full path of the php program (C:\wamp\bin\php\php5.3.10. in my case) every time you need to run a script, you can set the environment variable in windows to point to this path under:
right-click My Computer >>Properties >> System Properties>>Advanced tab >> Environment Variables.