Skip to content
Home » How to Execute PHP File From Command Line

How to Execute PHP File From Command Line

To Execute PHP File From Command Line, we can use 2 methods to execute the PHP file code by PHP command,

  1. By using XAMPP Shell or Command line.
  2. Inbuilt command line of Windows OS.

Note: If you want to use inbuilt command line interface of Windows OS, you have install PHP manually from PHP official package. Here is the complete step by step process to install PHP How To Install PHP In Windows 10.

Execute PHP File Using XAMPP Shell

Steps to Execute PHP Code Using XAMPP Command Line

  • If you do not have the XAMPP package, install it from the official site Download XAMPP (apachefriends.org)
  • Open the XAMPP control panel by clicking on the icon.
  • Click on the Shell option in the sidebar of the control panel.
  • It will open the command line then you go for the file path by using the CD command.
  • At last, run the PHP file by using below PHP command.

XAMPP Shell for Run PHP Script
XAMPP Shell for Run PHP Script

Execute PHP File Using Inbuilt Command Line

Here are some major steps to execute PHP code using the Windows command line interface,

  • Install PHP by official PHP package How To Install PHP In Windows 10.
  • Set the path of PHP in the environment variable at the time of PHP installation.
  • Open the CMD interface and run the below command.
Run PHP on Command Line Interface
Run PHP on Command Line Interface

Here is the complete step-by-step process of How to run the PHP file from the command line interface of Windows and XAMPP Shell.

If you get something error in implementation please comment below.

Also Read:

Happy Coding..!

Was this article helpful?
YesNo

Leave a Reply

Your email address will not be published. Required fields are marked *