Back to the article list

22 Dec 2014

Making a Symfony application bootable again with Doctrine DBAL 2.5

SymfonyInsight uses a dynamic analysis engine to boot applications in order to find bugs and errors impossible to find by a simple static analysis. That's why, when your application is not bootable, SymfonyInsight triggers a code quality violation and disables some analysis rules.

In normal circumstances this error is rarely seen in the analyses performed by our users, but a recent change introduced by the 2.5 version of the DBAL project is breaking lots of projects on SymfonyInsight.

Basically, when calling the getDatabasePlatform() method in DBAL 2.5, that call needs to establish a connection in order to evaluate the appropriate database platform class if Doctrine\DBAL\Connection is not already connected.

The workaround is to explicitly configure the database server version used by Doctrine. In Symfony applications, this is as easy as declaring the server_version parameter of Doctrine DBAL in the app/config/config.yml file. The value of this parameter must be the version number of your database server. For example, if you use MySQL, execute mysql -V to get the version and configure it as follows:

# app/config.yml
        server_version: 5.6

In addition to making your application bootable again for SymfonyInsight, this new parameter will save your application one database call/connection on production environment.

comments powered by Disqus