Back to the article list

09 Nov 2013

Analyzing a Project depending on MongoDB

A good practice when a project depends on MongoDB is to add it as a C dependency in your composer.json file:

    "require": {
        "ext-mongo": ">=1.2.12,<1.6-dev"

When running an analysis on a project, the rules that are activated depends on a number of different factors like the type of your project and the ability to boot the Kernel (at least for a Symfony2 application.) And booting a project is only possible after running the composer install command.

So, if MongoDB is not available or if the MongoDB PHP extension is not installed on the machine used to run the analysis, Composer will fail and a large number of interesting rules will be automatically disabled.

Good news is that enabling MongoDB is as simple as adding this snippet of code in your project configuration:

pre_composer_script: |
    yes '' | pecl install mongo

php_ini: |

Of course, this snippet can be used if you need any other C extension that is not available by default.

For more tips about SymfonyInsight, have a look at our FAQ.

comments powered by Disqus