Running Symfony CMF With Gaudi

Emmanuel Quentin
Emmanuel QuentinFebruary 09, 2014
#cms#oss#tutorial#php

Symfony CMF is a new Content Management Framework based on Symfony 2. This project won the Symfony Open-Source Application Award 2013, and is used at marmelab for a project with more than 900K documents.

Symfony CMF requires several third-party components to be installed: Jackrabbit, MySQL, Apache, and of course PHP. Gaudi simplifies the build of linked components, so it will be hepful to setup and run a Symfony CMF project. Gaudi runs a Docker container for each required components defined in a simple configuration file.
It was instroduced in a previous post.

Symfony CMF

Creating The Configuration File

The .gaudi.yml file lists all components required to run the Symfony CMF Sandbox :

Jackrabbit

You may notice that it is similar to the configuration file of the Gaudi Symfony tutorial.

Instead of starting a MySQL server, we start Jackrabbit, and make it listen on port 8082.

As Docker does not keep data when a container is removed, we need to mount a folder from the host machine into /opt/jackrabbit/jackrabbit (where Jackrabbit stores its documents).

Php-fpm

The Jackrabbit server is linked to the app application, which runs a PHP-FPM server. During the build of app, we tell Gaudi to:

  • install php5-gd & php5-intl required by Symfony CMF
  • mount the current folder to /var/www
  • listen to the port 9000

Apache

The Apache server is called app, and is configured to:

  • mount the current folder to /var/www
  • listen on the 8080 port
  • redirect all requests to the port 80 of the container
  • redirect all Fast-CGI requests to the app application
  • define the DocumentRoot to /var/www/web (required by Symfony)
  • enable mod_rewrite

Starting All Components

To start all the 3 components (Apache2, PHP-FPM & Jackrabbit), just run :

Wich will output something like :

Installing Symfony Cmf

Attach the app container to run some commands :

Configuring Symfony CMF

Docker injects some environment variables for linked containers. In this example, the injected variables in the app container are:

We need to inject some on them in the Symfony configuration by creating a new app/config/parameters.php file:

Include this file in the app/config/config.yml after - { resource: phpcr.yml } :

Install all dependencies :

Finaly create the Jackrabbit workspace :

You are now go to go and check the result at http://localhost:8080/hello.

Feel free to give me some feedback or bug report in Gaudi's project.