Connect to a database

During the analysis of Symfony projects, SymfonyInsight tries to boot your application to analyze the content of your service container and compute violations about it.

Yet, in some cases you can see "Dependencies cannot be installed" or "SymfonyInsight was not able to boot your Symfony application" error. The reason is that SymfonyInsight always try to install and boot your application before analyzing it. When installing your project's dependencies, the composer install command is executed. In turn, this command executes the cache:clear command, which tries to boot the kernel of your application.

If your application tries to connect to a database when booting its kernel, SymfonyInsight won't be able to boot it and your project will only be partially analyzed.

You cannot connect to a local database when running code analysis. In fact, this is even considered a bad practice. The reason is that it implies that every single kernel boot (so every single request or command) will make a connection even if it's not used afterwards. This increases the load on the database for no use, can degrade performance, or can even disallow simple maintenance tasks like clearing the cache if a connectivity issue arises.

If you only require a database server for the composer install step, you can install it using apt-get. You then need to start it using the pre_composer_script section of the configuration.

As SymfonyInsight analyses are done in two steps, starting a server in the pre_composer_script section won't make it available for the analysis and kernel boot.