Pino
Pino

Reputation: 135

How can I access the Doctrine profiler in production environment?

I have a filter set up to count the number of queries executed and write something to my database if they exceed a certain limit.

It works fine in my development environment, but when I test it in my production environment my database doesn't return a profiler anymore. I suposse it is a setting which enables the database profiler for the development environment, but I can' seem to find it.

I use Symfony1.4 and Doctrine.

$database = $databaseManager->getDatabase($name);
if ($database instanceof sfDoctrineDatabase && $profiler = $database->getProfiler())
{
    $events = $profiler->getQueryExecutionEvents();
}

Upvotes: 2

Views: 1105

Answers (1)

j0k
j0k

Reputation: 22756

You can force the profiler for a connection inside your database.yml with the profiler option:

prod:
  master:
    class: sfDoctrineDatabase
    param:
      profiler: true
      dsn: 'mysql:host=localhost;dbname=dbname'
      username: username
      password: password

Indicates whether to output doctrine log to the debug toolbar. The default value of profiler depends on the environment. In development environment the default value is true, otherwise - false.

Upvotes: 3

Related Questions