Symfony 6 + Doctrine - How to configure Doctrine\DBAL\Driver\OCI8\Middleware\InitializeSession?

672 Views Asked by At

The Doctrine\DBAL\Event\Listeners\OracleSessionInit was deprecated in DBAL 3.5 (https://github.com/doctrine/dbal/blob/3.5.x/UPGRADE.md) in favor of the Doctrine\DBAL\Driver\OCI8\Middleware\InitializeSession.

How should I setup the application with a new middleware? The documentation (https://symfony.com/bundles/DoctrineBundle/2.4.x/configuration.html#oracle-db) still show an old way.

I tried to use driver_class and wrapper_class options, but it does not work.

2

There are 2 best solutions below

0
Noom073 On BEST ANSWER
oracle.listener:
        class: Doctrine\DBAL\Driver\OCI8\Middleware\InitializeSession
        tags:
            - { name: doctrine.event_listener, event: wrap }

I hope this can help you.

0
Forfarle On

You should use the new middleware system. Using services.yaml definition isn't enough if you have another database systems configured because you will get errors when use them.

Create a middleware extending the InitializeSession class and specifying the Oracle connections like here https://stackoverflow.com/a/76953879/3153254