Shiphp The PHP Developer's Guide to Docker

Latest Blog Posts

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