Disable Doctrine Migrations Check in Symfony

I wanted to set up my own Symfony Skeleton project and get all my favourite packages and configuration set up. One need I have is to have Doctrine and Doctrine Migrations packages installed but I don’t want them to be used (yet). The problem is that I was finding a lot of errors in my logs like this:

app.ERROR: error while trying to collect executed migrations {...} (File: /vendor/doctrine/doctrine-migrations-bundle/Collector/MigrationsCollector.php | Line: 41)

doctrine.INFO: Connecting with parameters array{...} (File: /vendor/doctrine/dbal/src/Logging/Driver.php | Line: 31)

This told me that Symfony was trying to connect to the non-existent database on every request. Even though my application had no need for a database connection yet.

I wanted to disable doctrine by default or disable the migration checks happening on every page.

Went down a rabbit hole searching for ways to turn off or disable doctrine or the migrations but came up empty. Determined that the problem is the Symfony Debug/Profiler Bar that displays at the bottom of the page in the dev environment. The profiler collects the current status of the migrations.

I was able to solve this issue and disable the migrations check by setting the enable_profiler setting to false in the config/packages/doctrine_migrations.yaml file.

        # namespace is arbitrary but should be different from App\Migrations
        # as migrations classes should NOT be autoloaded
        'DoctrineMigrations': '%kernel.project_dir%/migrations'
    enable_profiler: false #'%kernel.debug%'

Leave a Reply

Your email address will not be published.