Fork me on GitHub

How to make Symfony faster

Jul 14, 2015

By turning your Symfony application into a FastCGI application, you can keep the application in memory between request cycles.

Before doing this, please read the post on things to consider when using PHPFastCGI with your application.

To do this, open the terminal in your project directory and run the following command:

php composer.phar require "phpfastcgi/speedfony-bundle"

This command adds the Speedfony Bundle to your composer dependencies.

Now you need to register the bundle in your AppKernel.php file:

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
  public function registerBundles()
  {
    $bundles = array(
      // ...
      new PHPFastCGI\SpeedfonyBundle\PHPFastCGISpeedfonyBundle(),
    );

    // ...
  }
// ...

Your application can now be run as a FastCGI application listening on FCGI_LISTENSOCK_FILENO (stdin) using this command:

php app/console speedfony:run --env="prod"

You can also configure the FastCGI application to listen on a TCP address using the ‘port’ and ‘host’ options:

php app/console speedfony:run --env="prod" --port 5000
PHPFastCGI

GitHub / Twitter / Packagist
irc.freenode.org #phpfastcgi