## Run .php file in Windows Command Prompt (cmd)

run php from command line windows xampp
execute php file from command line linux
run php file from command line
run php file from command line ubuntu
run php code from command line
php command line arguments
run php function from command line
run command php windows

I want to run a .php file in windows cmd. I followed this (suggestion) php is not recognized as an internal command (in Windows)

But it did not work.

I tried this command prompt: C:\Windows\system32> cd \myfolder

And within myfolder I did as follows: C:..\myfolder> php file.php but I get an error "php is not recognized as internal or external"

But when I try without php command like this; C:..\myfolder> file.php it just opens in notepad, yet I want to run it in cmd. How can I do it?

If running Windows 10:

2. Type path
3. Click Edit the system environment variables (usually, it's the top search result) and continue on step 6 below.

If on older Windows:

1. Show Desktop.

2. Right Click My Computer shortcut in the desktop.

3. Click Properties.

4. You should see a section of control Panel - Control Panel\System and Security\System.

6. Click Enviornment Variables towards the bottom of the System Properties window.

7. Select PATH in the user variables list.

8. Append your PHP Path (C:\myfolder\php) to your PATH variable, separated from the already existing string by a semi colon.

9. Click OK

11. Type PATH, press enter

12. Make sure that you see your PHP folder among the list.

That should work.

Note: Make sure that your PHP folder has the php.exe. It should have the file type CLI. If you do not have the php.exe, go ahead and check the installation guidelines at - http://www.php.net/manual/en/install.windows.manual.php - and download the installation file from there.

Run .php file in Windows Command Prompt (cmd), If running Windows 10: Open the start menu; Type path; Click Edit the system environment variables (usually, it's the top search result) and  To open windows command line, Press (windows + R) and type “cmd” and hit enter. It will open windows command prompt shown as below. Now type “php -v” to check php version. If this command works fine and is not produce any error then we can assume that php is working in windows command line.

you can for example: set your environment variable path with php.exe folder e.g c:\program files\php

create a script file in d:\ with filename as a.php

open cmd: go to d: drive using d: command

type following command

php -f a.php

you will see the output

How to run any PHP Script as a Windows Service (8/2012/7/2008 , Start a command prompt (Start button > Run > cmd.exe). In the window that appears, type the full path to the PHP executable (php.exe)  Running PHP From Windows Command Line. Since PHP is a server side scripting language, a lot of website development using PHP is done on a live web environment. However, PHP does allow you to install it and run scripts on your local machine with no web access needed. Running PHP from Windows command line can be especially useful when trying to rapidly develop custom scripts, or to read and modify local files.

You should declare Environment Variable for PHP in path, so you could use like this:

C:\Path\to\somewhere>php cli.php


You can do it like this

How to execute PHP code using command line ?, You just follow the steps to run PHP program using command line. Open terminal or command line window. Goto the specified folder or directory where php files  To run PHP from command line in windows you just have to add php executable file path to system variable correctly. If you have installed XAMPP, and want to use command line to run PHP on Windows, here is this helpful article for you. I have already installed XAMPP in my local pc having windows 7 OS.

It seems your question is very much older. But I just saw it. I searched(not in google) and found My Answer.

So I am writing its solution so that others may get help from it.

Here is my solution.

Unlike the other answers, you don't need to setup environments.

all you need is just to write php index.php if index.php is your file name.

then you will see that, the file compiled and showing it's desired output.

How to run php script in command prompt windows, The above program can be executed using the EditRocket Tools -> PHP -> Execute Program option, or you can execute it from a command prompt. To execute  How can I run a PHP script from the command line using the PHP interpreter which is used to parse web scripts? I have a phpinfo.php file which is accessed from the web shows that German is installed. However, if I run the phpinfo.php from the command line using - php phpinfo.php and grep for German, I don't find it. So both phps are different.

Running php program on command prompt using WAMP, [code]C:\xampp\htdocs>php test.php Hello Team ,test.php file execute here C:\​xampp\htdocs> <?php Is PHP merely a set of Perl commands? if you want to execute php scripts through windows command line, then that is simple and easy​. When I click the run button it has to open the command prompt and run the main.bat file, but whenever I click run it says nothing. php windows batch-file share | improve this question

PHP Command line: how to run PHP from command line in Windows, There are no user contributed notes for this page. Features · HTTP authentication with PHP · Cookies · Sessions · Dealing with XForms · Handling file uploads  Start a command prompt (Start button > Run > cmd.exe) In the window that appears, type the full path to the PHP executable ( php.exe ) followed by the full path to the script you wish to run as a windows service.

How to Install PHP and Run PHP Programs on Windows, Press Windows+R to open “Run” box. Type “cmd” and then click “OK” to open a regular Command Prompt. Type “cmd” and then press Ctrl+Shift+Enter to open an administrator Command Prompt. Open Command Prompt from the File Explorer Address Bar In File Explorer, click the address bar to select it (or press Alt+D). Type “cmd” into the address bar and hit Enter to open the Command Prompt with the path of the current folder already set.