Search code examples
phpsymfonyrecipebundles

Can I add bundles to a Symfony 4 project that doesn't have a recipe for flex?


Is it possible to add bundles in Symfony 4 that doesn't have a flex recipe?

I would like to add the following bundle

https://github.com/KnpLabs/DoctrineBehaviors

to my symfony 4.0 project, but it doesn't have a recipe (https://flex.symfony.com/) available. So when I install it with composer and add the config to my services it complains that it doesn't know the bundle.


Solution

  • The role of a flex recipe is to automate registration of bundles in kernel, adding configuration stubs, and so on. If a bundle doesn't have a recipe, and you were able to install it with composer (which means that the package constraints allow Symfony 4) you have to configure the bundle manually, starting with adding the bundle to config/bundles.php:

    return [
        // ...
        Knp\DoctrineBehaviors\Bundle\DoctrineBehaviorsBundle::class => ['all' => true]
    ];