Laravel with docker-compose
So, I’ve been using Laravel with docker-compose for development for a while, and now I’m going to make a simple yet functional project skeleton based on a classic laravel/laravel package, and I’m going to document the whole process here.
This article is targeted at PHP devs that use or want to use Laravel, and are also using or willing to use containerized environments. I will also provide some tips & tricks for PHPStorm users, and in a follow-up post I will show how you can deploy this app to Google Kubernetes Engine in Google Cloud.
Prerequisites
I will suppose you have docker installed, as well as docker-compose. Some acquaintance with command line, Git and the wonderful Composer package manager is also a must. I will also suppose you have PHP installed locally. I am using a Linux laptop, things are going to be pretty much the same on Mac, and hopefully on Windows but I’m not sure.
Why bother?
Docker & docker-compose have been around for a while already, but are still rapidly growing in terms of adoption and features. For PHP and LAMP devs, containers allow for running different versions of PHP, MySQL, Apache/Nginx for different projects, as well as any other databases, caching servers etc. Running your project with docker-compose makes it isolated from the rest of your machine, and gives your the power to start/stop the whole project with a simple shell command. Read more about benefits of docker-compose for development in this blog post.