Last active
December 23, 2015 19:29
-
-
Save ostark/6683180 to your computer and use it in GitHub Desktop.
SF2 performance tweaks for fortrabbit
- /app/AppKernel.php
- /app/config/config_prod.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\HttpKernel\Kernel; | |
use Symfony\Component\Config\Loader\LoaderInterface; | |
/** | |
* Fortrabbit (or general NFS related) patch of Symfony AppKernel. | |
* | |
*/ | |
class AppKernel extends Kernel | |
{ | |
public function registerBundles() | |
{ | |
$bundles = array( | |
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), | |
new Symfony\Bundle\SecurityBundle\SecurityBundle(), | |
new Symfony\Bundle\TwigBundle\TwigBundle(), | |
new Symfony\Bundle\MonologBundle\MonologBundle(), | |
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), | |
new Symfony\Bundle\AsseticBundle\AsseticBundle(), | |
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), | |
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), | |
new Acme\HelloBundle\AcmeHelloBundle(), | |
); | |
if (in_array($this->getEnvironment(), array('dev', 'test'))) { | |
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle(); | |
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); | |
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); | |
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); | |
} | |
return $bundles; | |
} | |
/** | |
* Setup cache dir to tmp dir to speed up cache requests (avoid slow NFS access) | |
* | |
* @return string The cache directory | |
*/ | |
public function getCacheDir() | |
{ | |
// local tmp dir | |
$cache_dir = sys_get_temp_dir() . '/cache'; | |
if ($this->getEnvironment() == 'prod') { | |
if (!is_dir($cache_dir)) { | |
mkdir($cache_dir, 0777, true); | |
} | |
return $cache_dir; | |
} | |
return parent::getCacheDir(); | |
} | |
public function registerContainerConfiguration(LoaderInterface $loader) | |
{ | |
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
imports: | |
- { resource: config.yml } | |
framework: | |
validation: | |
cache: apc | |
parameters: | |
memcached.servers: | |
- { host: memcachecluster.frbit.com, port: 11211 } | |
services: | |
memcached: | |
class: Memcached | |
calls: | |
- [ addServers, [ %memcached.servers% ]] | |
doctrine: | |
orm: | |
metadata_cache_driver: apc | |
result_cache_driver: apc | |
query_cache_driver: | |
type: memcache | |
host: memcachecluster.frbit.com | |
port: 11211 | |
monolog: | |
handlers: | |
main: | |
type: fingers_crossed | |
action_level: error | |
handler: nested | |
nested: | |
type: stream | |
path: %kernel.logs_dir%/%kernel.environment%.log | |
level: debug |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment