Docker for PHP Developers

Learn How to Make PHP Development with Docker Feel like 127.0.0.1

"Docker for PHP Developers" is a book and video course that will teach you how to use Docker and PHP to create clean, repeatable development environments that are easy to understand.

Learn how Docker can simplify your PHP development setup and make it simple to share your environment with others. You will learn how to set up, manage, and deploy Docker applications with confidence.

Buy the Course Get a Sample

Get Free Book Samples

Try before you buy with a free sneak peek! Enter your email address and I'll send you two sample PDFs from my book and a few short videos and posts over the next week about using Docker with PHP. You'll also get semi-regular tips about Docker and updates on any course announcements.

What does the Guide Cover?

Docker for PHP Developers is a guide that combines a book and videos that help you master Docker as a full time PHP development environment.

Development Tools

  • Learn how to manage containers
  • Learn how to use Docker Compose
  • Use XDebug with Docker
  • Use PHP Composer with Docker

PHP Environment

  • Building PHP containers from scratch
  • Installing PHP modules
  • Managing module INI files
  • Per-environment configuration

Legacy Applications

  • Installing an older version of PHP
  • Hands-on example in the book getting a legacy version of a PHP app running
  • Security hardening

Build and Deployment

  • Automated builds with Docker Cloud
  • Private registries
  • GitLab Docker Builds
  • Application Deployment to Digital Ocean

Watch a Free Screencast Preview

Docker for PHP Developers includes over 7.5 hours of screencasts designed to help you learn how to use Docker as a PHP development environment.

* Book-only packages are also available.

Let me tell you about the time I first picked up Docker to use it in a PHP project:

It was hard learning how to use Docker because not only did I have to get used to the Docker environment—which has its own set of learning curves and challenges—I had to learn how to work with PHP, web servers, PHP modules, dependencies, and so forth in this new thing called a “container.”

I had to learn the nuances between Docker and a Vagrant virtual machine (which I was using at the time), how they are similar, and how they are different.

Docker presents some significant paradigm changes to how you think about a PHP environment.

PHP has some specific needs, because of the way PHP’s module system works, and how to properly configure PHP modules for different environments. In development, I need a particular configuration, and in production, I need another configuration.

I wanted a way to build a base image that I can use across all my projects.

Besides the runtime, “what are some ‘best practices’ for organizing my infrastructure code inside my project?”

Or in other words, “where do I put all this Docker-specific configuration and code within my project’s version control?”

I struggled for many hours across multiple types of project honing my code, configuration, PHP setup, and Nginx configurations.

Further, I struggled at first to adapt Laravel’s scheduler and queue patterns to Docker, because it’s much different than the traditional way of running everything on one virtual machine. The idea of using crontab in a container feels weird.

You have to break parts of your Laravel application into multiple containers, and figure out how to share the same Docker image between multiple types of containers that need the same Laravel code.

Fast forward to today, the tools around Docker have improved drastically. No longer will you need to dread moving your application to production or another machine.

Your container will be identical in production and development, and you can work on PHP 5.6 projects and PHP 7, without destroying your local machine’s setup.

You can use one Laravel image to run your web app, scheduler jobs, and queues across multiple containers running the same image. And my course can show you how, as we walk through setting up an entire Laravel app with Docker from scratch!

That’s why I’ve been working on my course Docker for PHP Developers since November 2016.

I have spent the time smoothing out the rough edges of adopting Docker with PHP, so you don’t have to. It will save you hours of searching stack overflow, and reading outdated tutorials, and you can learn how to level-up your Docker and DevOps skills in a couple of afternoons.

I’ve distilled three years of learning into an eight-hour course and a 220-page book!

Docker for PHP Developers is the guide I wish I had when I started learning Docker. It's everything I've learned and refined using Docker on dozens of projects over the last three years combined into one course.

No Complicated Tools Required

Learning Docker doesn't have to be complicated. In fact, I think the goal of Docker should be to simplify your application environment, not increase complexity. I'll show you how to build practical, simple, clean Docker images from scratch without extra 3rd party tools or libraries—just Docker.

Learn how to create environments that take minutes to install instead of hours or days. Think of Docker images with PHP code as a single artifact that is ready to run your application.

Your application deployments will be extremely predictable and reliable. I work with leading frameworks like Laravel and Symfony, so you'll be able to use the PHP frameworks you love with Docker after going through this guide.


The Docker PHP Videos

Docker for PHP Developers includes over 7.5 hours of screencasts.

Introduction and Setup

1 - Welcome

2 - Install Docker for Mac

3 - Install Docker for Windows

4 - Install Docker for Ubuntu

5 - Docker Machine Intro

Docker Container Basics

6 - Basic Docker Commands

7 - Docker Compose

Docker LAMP

8 - Apache Setup

9 - MySQL in Docker

10 - Setting Up PHP Modules and Apache Modules

11 - Data Volumes

PHP Composer

12 - Installing Composer in Docker

13 - Private Composer Packages

14 - Caching Composer Dependencies

Web Servers

15 - Nginx (Part 1)

16 - Nginx (Part 2)

17 - Caddy HTTP/2 Server

Working With Legacy Apps

18 - Introduction

19 - Legacy App Setup

20 - Docker Compose and Apache Configuration

21 - Running a Legacy Console

22 - Composer and phpdotenv

23 - Configuring ENV with phpdotenv

24 - Improved Database Configuration

Custom Docker Commands

25 - The CMD Setup

26 - Using Confd for Configuration Management

27 - Adding Confd to the CMD Script

28 - Using Consul with Confd for Configuration Management

Working with Docker Registries

29 - Docker Registry Setup

30 - Pushing Images to Docker Hub

31 - Automate Builds with Docker Cloud

32 - Automate Builds with GitLab

33 - Automate Builds with GitLab CI Pipelines

34 - Extending Custom Base Images

Deployment

35 - Simple Docker Machine Deployment

36 - Docker Swarm Overview


Setting up Laravel and Docker

These videos are available in the
Complete Video Bundle

1 - Laravel Getting Started

2 - Copying Files and the Apache Vhost

3 - Apache Permissions

4 - Apache Mod_rewrite

5 - Creating a Docker Compose File

6 - Setting up MySQL

7 - Adding a Redis Service

8 - Configuring an App Volume for Instant Code Changes

9 - Docker and XDebug Setup

10 - A Flexible XDebug Configuration

11 - A Custom Start Script for Laravel Projects

12 - Running the Laravel Scheduler and Queue in Docker

13 - Improving the Scheduler

14 - Improving the Queue

15 - Adding a php.ini File

16 - Opcache Setup

17 - Using Nginx with Laravel

18 - Switching the Scheduler and Queue to Supervisor

19 - Copy vs. Add

20 - Automated Builds with GitLab CI - Intro

21 - Automated Builds with GitLab CI - Composer Build

22 - Automated Builds with GitLab CI - Frontend Build

23 - Automated Builds with GitLab CI - Application Docker Build

24 - Automated Builds with GitLab CI - Application Docker Build with Tags

What's Inside the Book

Chapter 1 Introduction to Docker

We'll jump right in and install Docker, with installation steps for Mac OS X, Linux, and Windows. Then, you'll run your first container to verify that your setup is working properly.

Chapter 2 PHP Container Basics

Learn your way around Docker with hands-on commands. We'll start off with the basics so you can learn how build your first Docker image from scratch and how to run it. We'll then go over customizing a PHP INI file.

Chapter 3 LAMP with Docker

Learn how simple it is to build your own LAMP stack with Docker, without any 3rd party tools. You will also learn how to install and configure PHP modules, all while versioning your configuration in your projects.

Chapter 4 Development Tools

Learn how to master Xdebug with Docker with a step-by-step guide that shows you how to install Xdebug with a reusable configuration. You'll also learn how to remove Xdebug when you deploy Docker to production environments.

Chapter 5 Composer PHP

Are you curious how to use PHP Composer with Docker? You will Learn how to install the Composer CLI tool and install your application dependencies while building a Docker image. Learn how to install private composer repositories without leaving a trace of sensitive API keys or SSH credentials. Learn how to cache Composer dependencies for faster image builds.

Chapter 6 PHP-FPM and Webservers

Running a Webserver in Docker is a little different than on a traditional server. We cover installing Nginx and PHP-FPM and how they communicate in between Docker containers. We also walk through using Caddy Server, an HTTP/2 web server with automatic HTTPS.

Chapter 7 Legacy PHP Applications

Let's face it, we all have that legacy application in our lives. This chapter will help you set up an older version of PHP with Docker and show you how to retrofit configuration in older applications.

Chapter 8 Custom Commands

Go beyond the basics of running a container with custom commands and learn how to customize your application startup and runtime. Learn how to use Confd with Consul to separate configuration management from infrastructure code.

Chapter 9 Docker Registry Builds

Learn how to take your Docker images to the cloud and share them with others. We'll cover how to push your Docker images to registries and automatically build them when you push code commits to GitHub and other services.

Chapter 10 Deploying Docker

Take your first steps in deploying Docker to Digital Ocean with Rancher. Deployment is a big topic, and this chapter is a perfect first step for Developers. Learn how to push your image builds to Rancher from the command line with Rancher Compose.

Nice Stuff People are Saying

Get Docker for PHP Developers

Get an early release copy at a discount price on the new video courses!

Docker for PHP Developers - Complete Video Bundle

Complete Video Bundle

Comes with full series of 60+ videos on getting started with Docker (34 videos) and setting up Docker for Laravel (24 videos). Comes with the Docker for PHP Developers eBook, plus the source code of two starter projects. Learn how to organize your projects with Docker and the latest Laravel and Symfony frameworks.

  • Stream and Download all 60+ lessons
  • Access to any future videos added to the course
  • Starter project source code for Laravel 5.5 and Symfony 4, based on my professional Docker setup. Both starter projects use PHP 7.2.
  • The 222-page Docker for PHP Developers Book
  • Beautiful handcrafted PDF design
  • Basic ePub and Mobi formats included
Here's the breakdown for team pricing:
  • 3 Developers — $345
  • 5 Developers — $575
  • 8 Developers — $880
  • 10 Developers — $1,100
  • 15 Developers — $1,575
  • 20 Developers — $1,980
  • 25 Developers — $2,475

Docker for PHP Developers - Starter Video Bundle

Video-only Bundle

Comes with full series of 60+ videos on getting started with Docker (34 videos) and setting up Docker for Laravel (24 videos). Comes with the source code of two starter projects. Learn how to organize your projects with Docker and the latest Laravel and Symfony frameworks.

  • Stream and Download all 60+ lessons
  • Access to any future videos added to the course
  • Starter project source code for Laravel 5.5 and Symfony 4, based on my professional Docker setup. Both starter projects use PHP 7.2.
  • Does not include the eBook (see the Complete Video Bundle)

Book-only Options

Docker for PHP Developers Premium Edition

Starter Book Bundle (book + code)

Comes with the book, plus the source code of two starter projects. Learn how to organize your projects with Docker and the latest Laravel and Symfony frameworks.

  • Starter project source code for Laravel 5.5 and Symfony 4, based on my professional Docker setup. Both starter projects use PHP 7.2.
  • The 222-page Docker for PHP Developers Book
  • Beautiful handcrafted PDF design
  • Basic ePub and Mobi formats included

Docker for PHP Developers Starter Edition

Book Only

Learn how to use Docker as a full-time development environment for PHP, with a beautiful, handcrafted book that will help you get from zero experience to Docker user quickly.

  • The 222-page Docker for PHP Developers Book
  • Beautiful handcrafted PDF design
  • Basic ePub and Mobi formats included

Paul Redmond

About the Author

Hello! I'm Paul Redmond. I'm a full stack developer writing stuff with Laravel, Vue.js, and Docker. I am passionate about being productive, writing clean code, and creating simple infrastructure.

I am the author of Writing APIs with Lumen, now published with Apress as Lumen Programming Guide. I am also a staff writer for Laravel News. You can find me on Twitter as @paulredmond.