Deploying a Symfony2 and Composer app on PagodaBox
Monday, 16 April 2012 10:06

I have been working on a little pet project and wanted to put it up somewhere to show to a few people how it was going. I wanted something really simple so I decided to give the PHP PaaS solutions a try. Its a very simple Symfony 2.1 based app using Composer for vendor management, so I went on a quest to see what could be done and how.

I have always liked Orchestra, especially because I know the whole crew, but I was left stranded on how I could run the composer commands I needed after deploy. The feature was not done yet, so I moved onto Pagoda Box, thinking I was going to hit the same wall. I was pleasantly surprised that there was a solution and decided to give it a try.

It was mostly painless, but a few quirks kept me up late chatting with their excellent and very friendly support staff. So I decided to write up a few line about it.


The Boxfile defines all the config for your app and that’s where the magic happens. This is basically the extent of changes you need to make to your application.

Basic configuration

Some of the configuration is straight forward, so let’s get them out of the way. Be sure to adjust between app and app_dev accordingly.

        name: mysf2site
        document_root: web
        default_gateway: app.php
        index_list: [app.php]
        php_version: 5.3.8

Writable directories

As soon as you deploy a Symfony app you remember that you need to make the cache and logs folders writable or you will get a very nice blowup in your face. Pagoda let’s you do this but there is a couple thing you should know.

The writable directories configuration is meant for directories your “Web” role will write into. This means uploads, caching and related events, its does not relate to build steps. During the “build” step of your application (this is when you run Composer), everything is writable, so you don’t need to make your vendor folder writable for example.

Writable folders are always empty after deploy. This means if you decide to make your app folder writable because you have the crazy idea that it will be needed for bootstrap.php.cache, your deploy will give you a nice big empty app directory. So remember to only use this config for the folders that need it.

This is what it should look like:

  - app/cache
  - app/logs


So it might be a good idea to make sure all the extensions are there, this is very easy, and this is the list i came up with:

        - intl
        - mbstring
        - xsl
        - apc
        - mysql
        - pdo_mysql
        - zip

Notice zip, this is very important as Composer depends on this extension or falls back onto unzip, which is not a valid executable in a Pagoda server. The rest is standard Symfony stuff and personal choices.

The Configuration and Database

Personally I like to keep my parameters.yml file out of my repositories, to this was a challenge here, how do I create or copy in this configuration or how do i keep my config out of there.

Getting values into the system was a very nice suggestion on the Pagoda Help site. Using ENV variables you can inject this straight into the Symfony2 parameters.yml file, so i setup my database stuff for now with: SYMFONY__DATABASE__NAME which becomes in the yml file. Rinse and repeat for all DB variables and create these in the Dashboard with the proper values.

But I still needed to write the parameters.yml file to the system, and that’s where afer_build comes in. I needed to write multiple lines, so i cheated and went for a few echo calls.

Update: It appears you do not even need to have a parameters.yml file, you can go straight from ENV to Symfony as @igorwesome pointed out to me and this article

 - "echo 'parameters:' >> app/config/parameters.yml"
 - "echo ' database_driver: pdo_mysql' >> app/config/parameters.yml"
 - "echo ' database_host:' >> app/config/parameters.yml"
 - "echo ' database_port: 3306' >> app/config/parameters.yml"
 - "echo ' database_name:' >

Truncated by Planet PHP, read more at the original (another 3221 bytes)

read original article