symfony 3.1 Check if a bundle is installed

Carlos

I'm developing a bundle who has a dependency on another one.

In order to handle the case that the base bundle has not been installed I'll like to perform a "bundle_exists()" function inside a controller.

The question is: How can I have a list of installed bundles or How can I check for the name (eventually also the version) of a bundle.

Thanks.

Rooneyl

Your class needs to have access to the container object (either by extending or DI).
Then you can do;

$this->container->getParameter('kernel.bundles');

This will give you a list of bundles installed.

Update;
If you are in a controller that extends the Symfony\Bundle\FrameworkBundle\Controller\Controller or in a command class that extends Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand, you can just get the parameter.

$this->getParameter('kernel.bundles').

Else @Wouter J's answer is your best answer.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Lexik Bundle Symfony 3

From Dev

Symfony3 HWIOauth Bundle can't use/find Google Login-Check route

From Dev

Symfony 3: How to create a private bundle

From Dev

Unable to install bundle for Symfony 3 using Composer

From Dev

Sonata User Bundle + Symfony 3.x

From Dev

API Post to Sonata Media Bundle Symfony 3

From Dev

How to auto generate a bundle in Symfony3?

From Dev

Symfony 3 - Sonata Aplication Media Bundle error

From Dev

The program 'bundle' is currently not installed

From Dev

Gems not installed by bundle install

From Dev

Unable to configure Symfony (3rd party) bundle

From Dev

Symfony 3 + FOS REST Bundle: Normalize values before validation

From Dev

Symfony3 - MISD Phone Number Bundle format

From Dev

What is wrong with my bundle extension class ( symfony 3 )?

From Dev

Symfony 3 - Ckeditor bundle : Unrecognized options "template, template_parameters"

From Dev

Extract the current namespace, bundle, controller and action name symfony3

From Dev

Symfony 3 overwrite FOS UserTemplate - but put the Views in my Bundle

From Dev

Check if a double = 1/3

From Dev

Symfony call a bundle in an other bundle

From Dev

Installed Symfony 3 demo project Not finding css or js files

From Dev

OSGi add bundle listener to installed bundle

From Dev

Symfony Add Bundle

From Dev

Symfony solr bundle 2.8 +

From Dev

sonata admin bundle symfony

From Dev

New symfony bundle, when

From Dev

Symfony Add Bundle

From Dev

Reusing Entities on symfony bundle

From Dev

Symfony solr bundle 2.8 +

From Dev

symfony shortCodes bundle