Run Symfony2 on AppFog?

🦖 This post was published in 2013 and is most likely outdated.

TL;DR You can’t (no shell access to run commands).

I have been trying to deploy a Symfony2 application on AppFog. I tried first a PHP Hello World, it was pretty easy. Then deploying a Wordpress was a little bit more challenging as you have to automatically hook up the database to Wordpress and tell Wordpress to use S3 to host any static content (AppFog does not offer persistent storage yet). But a complete Symfony2 application is a lot harder.

Here is my checklist of things a Paas have to support in order to run a complete Symfony2 application.

Open questions

I would be really interested if you have a way to go around one of these problems.

  • Run Symfony2 commands

    With Symfony2, you absolutely need to run commands in the production environment (cache, migrations, assets, vendors, …) and there is no shell access in AppFog. I haven’t found any way to get around this.

  • Run post deploy hooks

    Same idea as previously, there is no way to do that in AppFog yet.

  • Run cron jobs

    Same idea, there is some way to run crons but they can’t call a Symfony2 command. Vote for the feature request on AppFog support website!

Solved issues

  • Set web/ as the Document Root

    On AppFog, we can’t edit the virtual host configuration but we achieve the same goal by using URL rewritting with another .htaccess at the root directory.

  • Exclude app/cache, app/logs and web/bundles when deploying

    AppFog does not deploy with git but uses its own tool, af, which is similar to rsync. We can specify a .afignore file in the root directory that will be the equivalent of .gitignore.

  • Set the database parameters

    AppFog launches the database instance at the same time we deploy and passes the database parameters into the VCAP_SERVICES environment variable. So we can have a PHP config file (instead of Yaml) that reads the environment variable and save the parameters in the service container, like in the Wordpress example.

  • Have persistent storage for web/uploads

    AppFog does not offer persistent storage yet. We can use Gaufrette to use S3 as our file system. It does require to change our application code though.

Available out of the box

  • Make app/cache and app/logs writeable

    In AppFog, all the root directory and all subdirectories are writeable. Files are just not persistent but it doesn’t matter for those two directories.

  • Use root domain names

    AppFog supports root domain names out of the box.

  • Use web/app.php as front controller

    AppFog is using Apache with the directive AllowOverride All so the standard .htaccess is working to redirect all trafic to app.php.