Skip to content

Instantly share code, notes, and snippets.

@tadas-s
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadas-s/4d9fe00d099d907af8fe to your computer and use it in GitHub Desktop.
Save tadas-s/4d9fe00d099d907af8fe to your computer and use it in GitHub Desktop.
Relocate tmp folder on Symfony2

Relocate tmp folder on Symfony2

Doing Symfony2 in Vagrant and VirtualBox? Truth is that vboxfs is so called "network" filesystem and performance is poor. From time to time Symfony2 also experiences issues with cache:clear because of file locking. One solution for this is to move tmp folder outside the project to system temporary file folder.

<?php
use Symfony\Component\HttpKernel\Kernel;
class AppKernel extends Kernel
{
/* ... everything else is skipped ... */
public function getCacheDir()
{
if ($this->environment == 'dev') {
// use md5 of app root to avoid clashes with other Symfony2 apps
return '/tmp/'.md5($this->rootDir).'/cache/'.$this->environment;
} else {
return parent::getCacheDir();
}
}
}
@aivus
Copy link

aivus commented Aug 18, 2015

In this case we can't use Symfony IDE autocomplete (for example on PHPStorm)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment