Research Documentation 03 Local Php

Research Documentation 03 Local Php

03 - Local PHP

Technique 01: Using a Local Web Server Stack

One of the ways to run local PHP is by using a local Web Server Stack. Some popular stacks are: XAMPP, WampServer, and MAMP. For example, XAMPP is a popular PHP development environment. XAMPP is a completely free, easy to install Apache distribution that contains MariaDB, PHP, and Perl. With this platform, you're able to test code locally on your computer.

Technique 02: using PHP's Built-In Web Server

Another way of running local PHP is by using PHP's built-in web server. The built-in web server can be run on any computer that has PHP installed. The PHP built-in server can be accessed from the computer's terminal app. Once in the termainal, you want to navigate to the folder where your PHP file resides and run this command:

 $ php -S localhost:8000

This binds a sort of pop-up web server you can access by going to the localhost:8000 URL in your web browser where you can execute your PHP scripts as needed. While this built-in server is great for development, it is not suitable for production.

Technique 03: Using Docker

Docker is a platform that allows you to create isolated environments using containers. You can set up a container for PHP development. These containers set up local services, like a database. In order to use this method, you will also need to install PHP extensions.

Summary of the Documenation

Overall, there's quite a few ways to run PHP locally. Some pros of running PHP locally include: faster development cycle, it's cost-effective, the environment is customizable (meaning you have full control over the server and configurations), safe testing because there's no impact on a live site, and convenience -- no need for an internet connection to work on your projects! However, some of the cons of running PHP locally include: Limited resources -- local machines may have limited resources over dedicated servers, consistency issues between local and production environments, complexity in the set up depending on which method is being used, and limited collaboration if you're working on something for a team development project.