03 Local Php 03 Local Php

03 — Local PHP

Technique 01: Command Line

PHP code can be run from the system command line. On MacOS and Linux, the required PHP setup files can be installed from directly within the command line. On Microsoft Windows, these files will need to be downloaded from the PHP official website, PHP.net. Once these files are downloaded and installed, follow these steps to run a PHP script file of your choice.

  1. Open the command line window if you haven't done so already.
  2. Open the file browser and navigate to the file you want to run.
  3. Copy the filepath as text to the clipboard.
  4. Enter one of the following commands into the command line, replacing filepath with the filepath for the file you want to run.
    • php filepath
    • php -f filepath

Alternatively, you can enter PHP code directly into the command line. To do so, enter the following command into the command line, adding your desired PHP code after -r. (You'll need to surround your PHP code with single quotation marks.)

php -r

Technique 02: XAMPP

XAMPP is a free open-source Apache distribution developed by Apache Friends. XAMPP is available for computers running macOS, Linux, or Microsoft Windows. XAMPP comes equipped with PHP, Perl, and MariaDB. You can download XAMPP from the Apache Friends official website. Once you have downloaded and installed the appropriate version, open the XAMPP Control Panel and start the desired server(s). The available servers are as follows.

Technique 03: WampServer

WampServer is a web server stack package created and developed by Romain Bourdon. WampServer is available exclusively for Microsoft Windows devices. WampServer comes equipped with Apache, MySQL, and PHP. You can download WampServer from the WampServer official website.

Local PHP — Benefits and Malefits

Benefits

Malefits