user3440145 user3440145 - 2 years ago 98
PHP Question

Symfony Bundle name for overriding files

When extending/overriding a Bundle in a Symfony (3.0.x) project one adds the according folder to the "/app/Resources" folder. I got that.
What I did not get is how you know which name that folder should have.

The FOSUserBundle wants a folder named "FOSUserBundle".
The location of the bundle is "/vendor/friendsofsymfony/user-bundle/".

Obviously this is not the same name as the folder in the app/Resources location gets.

Where do I find the name or mapping information of a bundle that defines how to call the folder to be added?
Thank you in advance!

Answer Source

The bundle name is the short class name (the final part of the class name without the namespace) of the actual bundle class (see the code).

A few examples..

FOS\UserBundle\FOSUserBundle                  -> FOSUserBundle
Sylius\Bundle\ReviewBundle\SyliusReviewBundle -> SyliusReviewBundle
Sonata\BlockBundle\SonataBlockBundle          -> SonataBlockBundle

If you look at the class you use to add a bundle to your registered bundles you can get the bundle name from that.

So, for example (taken from the Sonata Block Bundle docs)..

public function registerBundles()
    return array(
        // Dependency (check that you don't already have this line)
        new Knp\Bundle\MenuBundle\KnpMenuBundle(),

        // Vendor specifics bundles
        new Sonata\CoreBundle\SonataCoreBundle(),
        new Sonata\BlockBundle\SonataBlockBundle(),

would be KnpMenuBundle, SonataCoreBundle and SonataBlockBundle.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download