Skip to main content

Simpiflied PHP development environment

Member for

2 years 2 months
Submitted by admin on

It is essential to run up an uncomplicated, highly performant speed and stable local development environment. The correct solution can become obfuscated with many options available to a developer.

The process required to produce a  website using PHP and MySql is not complicated and can be broken down into five steps. I've illustrated in the past using the following explanation :

A service that receives HTTP requests the routing to a PHP process executing the application while accesses verbose data, formatting the information and then returning it to the original user.

It may surprise you that a team can develop a micro-website using PHP, MySql by installing three pieces of software that are not memory exhaustive or challenging to install on any UNIX type operating system. Using Brew to install these packages helps in several ways. Below I explain what to install and why:

PHP CLI

All operating systems can install PHP from the terminal; you will require only the CLI for this development environment. Using Brew gives a team the ability to change the PHP version with a couple of commands making this solution powerful, or creating a script that automates the change is an alternative.

MySql or MariaDB

Either of the databases mentioned above will work and be installed using Brew in this environment. You will have to create a root password, so your PHP software has a way to connect to the database. This can be accomplished utilising the mysql_secure_installation,

DBeaver

If you're a database ninja, this is not required, and creating databases through the CLI works fine. Nevertheless, it will hasten development when you desire to access a database table and review an issue. Brew can also install this application.

How to use the development environment

After installing the software, open DBeaver login and create a database, then go to your PHP software root directory via the terminal and run the following command.

php -S localhost:8000

If you navigate to that address localhost:8000, you will be able to see PHP running beautifully in your web browser.  PHP has a built-in webserver (PHP built-in webserver) that is not production-ready but is quite powerful and has a lot of the functionality that Apache or Nginx has, making it easy to use for a development environment.

This uncomplicated solution will stun you with how often it can be used. We've used this process on WordPress, large Drupal and Symfony websites in design and development. However, if your need is greater functionality, using a Docker-based environment with the docker-composer is used by development teams worldwide to significant effect. Still, the complexity needed to run them can be replaced using the above solution.