How to Execute PHP File From Command Line

To Execute PHP File From Command Line, we can use 2 methods to execute 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 XAMPP package, install from official site Download XAMPP (apachefriends.org)
  • Open XAMPP control panel by clicking on the icon.
  • Click on Shell option in sidebar of control panel.
  • It will open the command line then you go for file path by using 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 environment variable at the time PHP installation.
  • Open 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
My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH, my native place in Odisha. I am a Web Programmer by profession and working on more than 50 projects to date. My passion is working on the web-based project using PHP and relate to all CMS and frameworks which is based on PHP.
Posts created 165

2 thoughts on “How to Execute PHP File From Command Line

Leave a Reply

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

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top
mariobet - supertotobet - escort -

takip7.com

We are now accepting Guest Posting and creation of Backlinks
This is default text for notification bar