MacBook avec code sur un bureau

Symfony – Doctrine – How to see where a sql query is executed

When using Doctrine, it is sometimes important to find where a SQL query is executed.

To do this, simply activate the following option in the Doctrine configuration

doctrine:
    dbal:
        default_connection: default

# A collection of custom types
        Types:
            # example
            some_custom_type:
                class: AcmeHelloBundleMyCustomType

Connections:
            # A collection of different named connections (e.g. default, conn2, etc.)
            default:
                dbname: ~
                host: localhost
                port:~
                user: root
                Password:~
                profiling_collect_backtrace: true

See the Doctrine configuration here

Once it is done, the stack trace will be visible in the profiler

Leave a comment