Our friends from PH2M and Kiboko asked us how we can still be using Docker on macOS despite the slowest IO ever.

This article explains how to install Sylius with Docker on macOS for development purposes, with fast IO.
Sylius is an Open Source e-commerce plateform on Symfony.

Actually we have searched for a long time in order to find the perfect solution using Docker on macOS, tryin many synchronization tools.
Because as you probably know the IO is very very slow on macOS with Docker for Mac.

But one day, Fabien Potencier took care of that issue for himself.

So, let’s start with the tooling.


  1. Docker: used for everything but PHP. (install Docker on macOS)
  2. PHP (and its extensions) on your machine: used for itself. (install PHP on macOS)
  3. The symfony binary: used to serve the application and run other commands with the correct PHP version. (install symfony bin on macOS)
  4. Composer, because we can’t do without. (install composer on macOS)

What a better example than installing Sylius on your machine?

We need PHP 7.3 at least, let check what we have:

$ symfony local:php:list
│ Version │             Directory              │ PHP CLI │   PHP FPM    │   PHP CGI   │ Server  │ System? │
│ 5.6.40  │ /usr/local/Cellar/php@5.6/5.6.40   │ bin/php │ sbin/php-fpm │ bin/php-cgi │ PHP FPM │         │
│ 7.0.33  │ /usr/local/Cellar/php@7.0/7.0.33   │ bin/php │ sbin/php-fpm │ bin/php-cgi │ PHP FPM │         │
│ 7.1.23  │ /usr                               │ bin/php │ sbin/php-fpm │             │ PHP FPM │         │
│ 7.1.30  │ /usr/local/Cellar/php@7.1/7.1.30_1 │ bin/php │ sbin/php-fpm │ bin/php-cgi │ PHP FPM │         │
│ 7.2.21  │ /usr/local/Cellar/php@7.2/7.2.21   │ bin/php │ sbin/php-fpm │ bin/php-cgi │ PHP FPM │         │
│ 7.3.8   │ /usr/local                         │ bin/php │ sbin/php-fpm │ bin/php-cgi │ PHP FPM │         │
│ 7.3.8   │ /usr/local/Cellar/php/7.3.8        │ bin/php │ sbin/php-fpm │ bin/php-cgi │ PHP FPM │ *       │

The current PHP version is selected from default version in $PATH

To control the version used in a directory, create a .php-version file that contains the version number (e.g. 7.2 or 7.2.15).
If you're using SymfonyCloud, the version can also be specified in the .symfony.cloud.yaml file.

I have my 7.3.8 version here, which is exactly what I need.

Requirements for Sylius

We also need a database. Let’s create a simple database using MariaDB:

$ docker run -d -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -p 3306:3306 mariadb:latest

Now we can use composer and the symfony binary to start our project.

Since we’ll probably run out of memory during the installation, let’s create a php.ini file:

$ echo "memory_limit=-1" >> php.ini
$ echo "[Date]" >> php.ini
$ echo "date.timezone=UTC" >> php.ini

This php.ini will be read by the symfony binary.

Install Sylius

Now we have all requirements, let’s install Sylius:

$ symfony composer create-project sylius/sylius-standard sylius
Installing sylius/sylius-standard (v1.6.0)
  - Installing sylius/sylius-standard (v1.6.0): Loading from cache
Created project in sylius
$ cd sylius && symfony console sylius:install -n -s default
Installing Sylius...
[OK] Sylius has been successfully installed.

Build the assets:

$ cd sylius && docker run --rm -t -v $PWD:/work -w /work node:10 bash -c "yarn install && yarn build"

Serve the application using the symfony binary

Now we have Sylius, let’s get to it!

$ symfony serve --daemon --dir=sylius

 [OK] Web server listening on (PHP FPM 7.3.8)

Want more?

To be sure that your sylius will always run on PHP 7.3:

$ cd sylius && echo "7.3" >> .php-version

Of course you can use the wip TLD in development with the symfony binary.
Read the doc!

We have a lot of Makefiles at Monsieur Biz and everything is perfectly smooth when you have more than one project like us.

Some useful articles: