Shiphp The PHP Developer's Guide

Interview with Luis Pabón: Creator of PHPDocker.io

As I’ve been learning more about the PHP and Docker ecosystem, I’ve been keeping an eye out for tools that PHP developers can use to speed up or improve their Docker workflows. PHPDocker.io is one such tool, and this week I got to interview the project’s creator, Luis Pabón. If you’re not familiar with it, PHPDocker.io is a free and open source... Read more

Running Wordpress with Docker Containers

The first exposure I had to PHP code was Wordpress, and ever since then the CMS has held a soft spot in my heart. Wordpress is used by millions of websites, so knowing how to set up a new instance and run it within Docker containers is a valuable skill for PHP developers. This tutorial will use the official Wordpress Docker image as well as som... Read more

Running a SlimPHP Application in Docker Containers

Using Docker to run a simple PHP web application is one thing, but how hard is it to install and run a small framework like SlimPHP in Docker containers? Let’s try it out! 1. Installing SlimPHP with Docker and Composer First we need to install SlimPHP into a new directory. Their documented installation instructions assume that you’ve got Com... Read more

Introduction to Writing Unit Tests in PHP with PHPUnit and Docker

Testing your code is a great way to improve quality and minimize bugs due to regression. PHP has a couple frameworks available for unit testing, but the most popular by far is PHPUnit. Because unit tests are going to be run on a variety of environments, running tests within Docker containers can make tests faster and more portable. This tutori... Read more

Switch Statements in PHP

While the switch statement isn’t as popular as conditional operators like if and elseif in PHP, it can still be useful when evaluating a number of possible outcomes. Using a switch statement is pretty simple, so let’s look at an example: <?php $var = rand(0,2); switch($var) { case 1: echo "The magic number is one."; bre... Read more

Running a PHP Application with Postgres and Docker

MySQL may be the standard choice in relational databases for PHP developers, but Postgres is a great option as well. The setup is very similar, and running Postgres and PHP within Docker containers is just as easy. 1. Create a PHP Script that Connects to Postgres Let’s start by writing a simple PHP script that will connect to a Postgresql da... Read more

Introduction to Interfaces and Abstract Classes

Object oriented languages like PHP have many tools for layering objects. Among PHP’s tools are interfaces and abstract classes which can be used in similar ways. I think many new developers tend to get confused and misuse them, so I’m hoping a little tutorial here will help. What is an Interface? An object interface in PHP is like a class te... Read more

Array Functions in PHP

Arrays are an important and widely used type in PHP. They are essentially ordered maps that allow developers quick access to key-value storage in their applications. For some basic array examples, see my previous post of working with arrays in PHP. PHP has over 75 array functions to help you manipulate and use arrays more efficiently. Since t... Read more

Running a Laravel Application in Docker

My favorite PHP framework for the past few years has been Laravel. It combines modern best practices with developer-friendly tools and pretty much all the common components that web developers need. There are already several good ways to set up a local development environment for Laravel including Homestead and Valet, but if you’re interested... Read more

Deploying a Docker-Based PHP Project with Hyper.sh

Once you’ve built a local PHP application using Docker, you have many options for hosting. One of my favorite tools is Hyper.sh, a container-based hosting platform that works for just about any Dockerized project you have including PHP projects. Hyper.sh charges you only for uptime on your containers, so it’s a perfect solution for continuous ... Read more