2

I'm on Windows 7 and i'm using vagrant box for a Symfony2 project.

I configured for nfs :

Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise32"
  config.vm.provision :shell, path: "bootstrap.sh"
  config.vm.network :forwarded_port, host: 1234, guest: 80
  config.vm.network "private_network", ip: "192.168.50.4"
  config.vm.synced_folder ".", "/var/www", type: "nfs"
  config.vm.provider "virtualbox" do |v|
    v.memory = 2048
    v.cpus = 2
  end
end

But my Symfony2 prokect is still veryyy slow.

What can i do ? I don't find a good solution...

Clément Andraud
  • 9,103
  • 25
  • 80
  • 158
  • possible duplicate of [Symfony2 +Vagrant performance - running slow - speeding up?](http://stackoverflow.com/questions/23983670/symfony2-vagrant-performance-running-slow-speeding-up) – Sidney Gijzen Nov 26 '14 at 17:29

3 Answers3

4

Overriding the cacheDir and logDir in app/AppKernel.php to a directory outside the NFS share usually gives quite a performance boost. For example:

public function getCacheDir()
{
    return '/tmp/symfony/cache';
}

public function getLogDir()
{
    return '/tmp/symfony/logs';
}

Only con: you can't inspect the cache and log files from your Host system. This could also mean that you loose autocompletion in your IDE (eg. PHPStorm with Symfony2 Plugin).

Fieg
  • 3,046
  • 1
  • 16
  • 22
2

Try to move vendor/ outside the shared directory.

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
Włodzimierz Gajda
  • 1,564
  • 12
  • 11
1

Since none of the methods for relocating the vendor folder worked for me in our project, I came up with this solution:

  1. Enable symlinks for Virtualbox in Vagrant. (This feature is disabled by default for security reasons, so do this only on developer machines.) See: Symbolic links and synced folders in Vagrant

    config.vm.provider "virtualbox" do |vb|
        vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
    end
    
  2. Create the "var" and the "vendor" folders outside of the shared directory (usually "/vagrant"). (Don't forget setting the proper owner for these folders.)

    mkdir -p /var/cache/MyProject/var
    mkdir -p /var/cache/MyProject/vendor
    
  3. Link them in the shared folder ("/vagrant"). (Delete the folders if they already exist.)

    ln -s /var/cache/MyProject/var /vagrant/var
    ln -s /var/cache/MyProject/vendor /vagrant/vendor
    
  4. Execute the "composer install" only after the previous steps.

I got a 4-6 times speedup just because of the relocation.

Crouching Kitten
  • 1,135
  • 12
  • 23