Run PHP from command line in windows

To run PHP from command line in windows you just have to add php executable file path to system variable correctly.

Run PHP from command line in windows and wamp
1. Right click on the Computer icon on your Desktop and choose Propertiesoption.
2. In the System window click on Advanced system settings in the left pane as highlighted below:

PHP run by command line

3. In the System Properties window select Advanced tab from horizontal menu at top and click on Environment Variables button given at the bottom of the window as shown below:

PHP run by command line

4. In the next window call Environment Variables as shown above, go to the System variable (second grid) and find a variable named Path and click Edit. If the Path variable is not present then click to New.
5. Get the php path where you have installed WAMP. In my case it’s C:\wamp64\bin\php\php5.6.25. Add this path to variable value in little dialog box that appeared.
6. Press OK and close all windows. Now you are ready, let’s test this

PHP run by command line

Run PHP from command line

  • Open command prompt by typing cmd in search box under your start menu.
  • Type php -v and press Enter
  • You will get version information as shown:

PHP run by command line

Furthermore I created a folder called vineet under D: drive and a file called test.php inside that folder. I simply wrote <?php echo “Vineet Kumar Saini”; ?>

PHP run by command line

The system variable is permanently set and  you can run PHP from command line in windows and wamp at anytime.

Advertisements
Categories: PHP & Joomla | Tags: , , , , | 1 Comment

Post navigation

One thought on “Run PHP from command line in windows

  1. Pingback: How to install Yii Framework in windows (Wamp Server) | Vineet Kumar Saini

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: