The final result

The main idea is that every service may or not become
a command. And the pattern would be the following:

$ docker-compose run <command> [--args]

Running a test suite, for example, could look like
this:

$ docker-compose run tests

To make typing easier, we can also add and alias to
the docker-compose run command. I'll call it dcr here:

$ alias dcr='docker-compose run'
$ dcr lol
ERROR: Can't find a suitable
configuration file in this
directory or any parent.
Are you in the right directory?
Supported filenames:
docker-compose.yml,
docker-compose.yaml

Alias created! It will complain though because there's no
compose file there yet. Let's create it then!

A basic compose file

So we're creating a brand-new project, huh? Let's
do it! Start by creating the project folder and
later on creating our docker-compose.yml file:

$ mkdir my-project
$ cd my-project
$ touch docker-compose.yml

I'll create then the common folders my skeleton
usually has. This will include a source folder,
a folder for tests and a folder for binaries.

Just run this:

$ mkdir -p src/ tests/ bin/ \
.conf/nginx/ var/

Now we can start working with our docker-compose.yml
file. It will contain all dependencies this project
might have.

The initial content in our docker-compose file should
be quite simple. Just type in the following:

# docker-compose.yml
version: '3'
services:

We will fill in the services right now! The most basic
one we need is, of course, composer.

Adding composer to docker-compose

Probably we're going to use php from inside the container.
So it doesn't make much sense to run composer from the
local machine, as php version might differ.

Refresh your browser tab and we shall
see a "Hello!" message on the screen!

Yeah, that's it! An awesome guide on setting
up a local development environment for
PHP very quickly using docker compose and enabled
to run tests with phpunit.

You might want to add some other things as well,
like databases, queues or maybe a Solr server...

You're free to evolve without messing up your whole
computer/server/repository.

If at some point you find that you'll need
specific things like a certain php extension or
something fancy about your containers, just
create your custom Docker and replace in your
docker-compose.yml file.

Don't forget to share with your lazy friends
whenever they start crying about a skeleton set up
for PHP.

And, of course, let me know if you faced any trouble
during this tutorial.