Hello everyone,
I was in need in the past days of using Symfony2 with Vagrant.

However, since Symfony is pretty heavy, you will need some twists to make it work as it’s supposed to without insane loading times.

First of all, you will need your Vagrantfile to be like this (you can change some variables as config.vm.box as you wish):

Vagrant.configure("2") do |config|
  config.vm.box = "deimosfr/debian-wheezy"

##  config.vm.provision :shell, path: "bootstrap.sh"
##  config.vm.network :forwarded_port, guest: 80, host: 4567
  config.vm.network "private_network", ip: ""

config.vm.synced_folder "www", "/var/www", id: "application", :nfs => true


  if Vagrant.has_plugin?("vagrant-cachier")
    config.cache.scope = :machine

    config.cache.synced_folder_opts = {
      type: :nfs,
      mount_options: ['rwx', 'vers=3', 'tcp', 'nolock']

    config.cache.enable :generic, {
      "cache"  => { cache_dir: "/var/www/app/cache" },
      "logs"   => { cache_dir: "/var/www/app/logs" },
      "vendor" => { cache_dir: "/var/www/vendor" },
  config.vm.provider "virtualbox" do |v|
    v.memory = 2048
    v.cpus = 4

Once you’re done installing your favorite box, you just have to install your LAMP or LEMP environment and then Symfony.

Once you are done you will have to modify the AppKernel.php file adding the methods that you can see down below accordingly:


class AppKernel extends Kernel
    // ...

    public function getCacheDir()
        if (in_array($this->environment, array('dev', 'test'))) {
            return '/dev/shm/appname/cache/' .  $this->environment;

        return parent::getCacheDir();

    public function getLogDir()
        if (in_array($this->environment, array('dev', 'test'))) {
            return '/dev/shm/appname/logs';

        return parent::getLogDir();

This was tested with Symfony 2 and produced very good results, reducing the loading time to more reasonable values like 2500 ms when using app_dev.php.


Need a custom made app/website?

I can help you automatize your company’s workflow.

Want a quote? Now is the right moment!