17 July 2017

Experimenting with Phalcon on Docker

Phalcon is a PHP framework that is implemented as a web server extension written in Zephir and C, aiming to boost execution speed, reduce resource usage, and handle more HTTP requests per second than comparable frameworks written primarily in PHP.

Phalcon logo
Is it really that much faster?

According to the benchmarks produced by the Phalcon team (here) it is significantly faster than other frameworks.  Of course there are other benchmarks available (like this one) which also find that it is significantly faster than traditional MVC frameworks.

Since the framework is and extension built in Zephir it's extremely fast and efficient.  Zephir offers native code generation (currently via compilation to C) which makes running it a lot faster than running PHP.

Phalcon has consistently been at the top of the performance charts for several years.

It's definitely worth experimenting with, and luckily they provide a full Docker stack that lets you get up and running in no time.

Of course it's important for me that I'm able to use Blackfire in my development environment so that I can profile it and measure performance changes.

To do this I used the instructions provided by Blackfire (here) and made just a few modifications.

To start with I amended the Phalcon docker file in docker/app/Dockerfile to include the command to install the Blackfire extension, like this:


Then I added the configuration into conf/php/fpm.ini like this:
And then of course I needed to include the Blackfire docker service, so I added it into the docker-compose.yml file like this:

Now when I bring up my Docker stack I have a fully functional Phalcon installation and my Blackfire profiling works right out of the box.
Needless to say that I'm very happy with the performance that the Phalcon "Micro" App is showing.