Docker PHP Tutorial - Learning Docker for PHP Developers
In this tutorial I'll take you on "my" journey of learning Docker as a PHP developer. Since I actively use everything explained along the way (and force it upon my team ;)) I can hopefully shed some light onto some more advanced issues like cross-OS-setups and seamless IDE integration.
Two words of caution:
- I tend to write rather lengthy, in-depth articles, so you should allocate some time to work it all through
- my main OS is Windows. Although most of the things should be easily transferable into OSX/Linux you might run into some quirks that I didn't encounter.
You can also find an overview of the published articles at the Docker PHP Tutorial site of my homepage.
Setup
Each tutorial is placed in a separate branch and has an accompanying article in my blog I recommend cloning the full repository and check out the corresponding branch for easy reference. Example:
mkdir -p /c/codebase
cd /c/codebase/
git clone https://github.com/paslandau/docker-php-tutorial.git
cd docker-php-tutorial
git checkout part_2_setting-up-phpstorm-with-xdebug-for-local-development-on-docker
Tutorials
Please subscribe to my RSS Feed and/or subscribe via email to be automatically notified when a new part gets published. I'll also probably brag about it on Twitter ;)
Playlist
There a YouTube playlist available containing all videos of the tutorial series.
Published
- Setting up PHP, PHP-FPM and NGINX for local development on Docker
- Setting up PhpStorm with Xdebug for local development on Docker
- Structuring the Docker setup for PHP Projects
- Docker from scratch for PHP 8.1 Applications in 2022
- PhpStorm, Docker and Xdebug 3 on PHP 8.1 in 2022
- Run Laravel 9 on Docker in 2022
- Set up PHP QA tools and control them via make
- Use git-secret to encrypt secrets in the repository
- Create a CI pipeline for dockerized PHP Apps
- A primer on GCP Compute Instance VMs for dockerized Apps
- Deploy dockerized PHP Apps to production on GCP via
docker compose
- Create a production infrastructure for dockerized PHP Apps on GCP
Planned (already used by us but not put into writing):
Roadmap (wow much want, such little time):
Setting up PHP, PHP-FPM and NGINX for local development on Docker
- Status: published ✓
- Link: https://www.pascallandau.com/blog/php-php-fpm-and-nginx-on-docker-in-windows-10/
- Branch: Part 1
A primer on Docker. What is Docker? How to install it / transition from Vagrant? How to interact with containers? How to organize multiple services (php-cli, php-fpm, nginx) via docker-compose?
Setting up PhpStorm with Xdebug for local development on Docker
- Status: published ✓
- Link: https://www.pascallandau.com/blog/setup-phpstorm-with-xdebug-on-docker/
- Branch: Part 2
Using docker for Development. How to configure PhpStorm to play nicely with Docker? How to setup Xdebug (including the solution for the dreaded 'Connection with Xdebug was not established.' error)?
Structuring the Docker setup for PHP Projects
- Status: published ✓
- Link: https://www.pascallandau.com/blog/structuring-the-docker-setup-for-php-projects/
- Branch: Part 3
Running a battle-tested development infrastructure for PHP developers in Docker. How to organize the
docker folder structure (e.g. shared scripts for containers)? How to establish a convenient workflow
via make
?
Docker from scratch for PHP 8.1 Applications in 2022
- Status: published ✓
- Link: https://www.pascallandau.com/blog/docker-from-scratch-for-php-applications-in-2022/
- Branch: Part 4.1
An update of the previous article (Part 3) with the learnings of the past 3 years:
- simplify the setup
- add more containers (redis, mysql, workers)
- prepare for additional environments (CI, production)
PhpStorm, Docker and Xdebug 3 on PHP 8.1 in 2022
- Status: published ✓
- Link: https://www.pascallandau.com/blog/phpstorm-docker-xdebug-3-php-8-1-in-2022/
- Branch: Part 4.2
An update of the previous article on setting up PhpStorm (Part 2) using the latest PHP version (PHP 8.1) as well as the latest Xdebug version (3). The article also covers additional debugging challenges (from the browser, from the CLI, from a long-running worker process).
Run Laravel 9 on Docker in 2022
- Status: published ✓
- Link: https://www.pascallandau.com/blog/run-laravel-9-docker-in-2022/
- Branch: Part 4.3
A step-by-step walk through to set up a new Laravel 9 project on the docker setup of this tutorial, using a couple of common Laravel components (Commands, Controllers, Queues, Databases).
Set up PHP QA tools and control them via make
- Status: published ✓
- Link: https://www.pascallandau.com/blog/php-qa-tools-make-docker/
- Branch: Part 5
Set up some PHP QA tools like phpcs
, phpstan
, etc. in the dockerized PHP application and
provide make
targets to run them either in parallel or individually.
git secret
to encrypt secrets in the repository
Use - Status: published ✓
- Link: https://www.pascallandau.com/blog/git-secret-encrypt-repository-docker/
- Branch: Part 6
Set up git secret
to encrypt and store secrets directly in a git repository. All required
tools are set up in Docker and their usage is defined via make
targets.
Create a CI pipeline for dockerized PHP Apps
- Status: published ✓
- Link: https://www.pascallandau.com/blog/ci-pipeline-docker-php-gitlab-github/
- Branch: Part 7
Create a CI pipeline using the dockerized setup introduced in the previous tutorial that can be executed on any CI provider. Concrete examples for Gitlab Pipelines and Github actions are included.
A primer on GCP Compute Instance VMs for dockerized Apps
- Status: published ✓
- Link: https://www.pascallandau.com/blog/gcp-compute-instance-vm-docker/
- Branch: Part 8
Getting started with the Google Cloud Platform (GCP) as infrastructure provider for a container registry to push and pull docker images as well as for virtual machines to run dockerized applications.
Deploy dockerized PHP Apps to production on GCP via docker compose
- Status: published ✓
- Link: https://www.pascallandau.com/blog/deploy-docker-compose-php-gcp-poc/
- Branch: Part 9
Introduce a prod
environment to build docker images that are then deployed "to production" on a
GCP VM to be executed via docker compose
as a proof-of-concept.
Create a production infrastructure for dockerized PHP Apps on GCP
- Status: published ✓
- Link: https://www.pascallandau.com/blog/create-production-infrastructure-php-app-gcp/
- Branch: Part 10
Create a production infrastructure for a dockerized PHP application on GCP using multiple VMs
and managed services for redis
and mysql
.
Deploy dockerized PHP Apps to production
- Status: draft
- Link:
- Branch:
Scaling Dockerized PHP Applications with Terraform and Kubernetes on GCP/AWS
- Status: Dream Caused by the Flight of a Bee Around a Pomegranate a Second Before Awakening
- Link:
- Branch: