WARNING: You are browsing the documentation for Symfony 2.8 which is not maintained anymore. Consider upgrading your projects to Symfony 4.2.

Switching the Profiler Storage

2.8 version
Maintained Unmaintained

Switching the Profiler Storage

By default the profile stores the collected data in files in the %kernel.cache_dir%/profiler/ directory. You can control the storage being used through the dsn, username, password and lifetime options. For example, the following configuration uses MySQL as the storage for the profiler with a lifetime of one hour:

  • YAML
    1
    2
    3
    4
    5
    6
    7
    # app/config/config.yml
    framework:
        profiler:
            dsn:      'mysql:host=localhost;dbname=%database_name%'
            username: '%database_user%'
            password: '%database_password%'
            lifetime: 3600
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    <!-- app/config/config.xml -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:framework="http://symfony.com/schema/dic/symfony"
        xsi:schemaLocation="http://symfony.com/schema/dic/services
            http://symfony.com/schema/dic/services/services-1.0.xsd
            http://symfony.com/schema/dic/symfony
            http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
    
        <framework:config>
            <framework:profiler
                dsn="mysql:host=localhost;dbname=%database_name%"
                username="%database_user%"
                password="%database_password%"
                lifetime="3600"
            />
        </framework:config>
    </container>
    
  • PHP
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    // app/config/config.php
    
    // ...
    $container->loadFromExtension('framework', array(
        'profiler' => array(
            'dsn' => 'mysql:host=localhost;dbname=%database_name%',
            'username' => '%database_user',
            'password' => '%database_password%',
            'lifetime' => 3600,
        ),
    ));
    

The HttpKernel component currently supports the following profiler storage drivers:

  • file
  • sqlite
  • mysql
  • mongodb
  • memcache
  • memcached
  • redis

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.