Important

You are browsing the documentation for version 4.2 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Create a Bundle

Create a Bundle Manually

First you need to specify name and namespace of your bundle. Symfony framework already has best practices for bundle structure and bundle name and we recommend to follow these practices and use them.

Let us assume that we want to create the AcmeNewBundle and put it under the namespace Acme\Bundle\NewBundle in the /src directory. We need to create the corresponding directory structure and the bundle file with the following content:

src/Acme/Bundle/NewBundle/AcmeNewBundle.php
 namespace Acme\Bundle\NewBundle;

 use Symfony\Component\HttpKernel\Bundle\Bundle;

 class AcmeNewBundle extends Bundle
 {
 }

Basically, it is a regular Symfony bundle. The only difference is in the way it will be enabled (see chapter Enable a Bundle).

Enable a Bundle

Now you have all the required files to enable the new bundle. To enable the bundle:

  1. Create Resources/config/oro/bundles.yml with the following content:

    src/Acme/Bundle/NewBundle/Resources/config/oro/bundles.yml
     bundles:
         - Acme\Bundle\NewBundle\AcmeNewBundle
    

    This file provides a list of bundles to register — all such files will be automatically parsed to load required bundles.

  2. Regenerate the application cache using the console command cache:clear:

    user@host:/var/www/vhosts/platform-application$ php bin/console cache:clear
    Clearing the cache for the dev environment with debug true
    

    Note

    If you are working in production environment, you have to use parameter --env=prod with the command.

Check if your bundle is registered and active with following command:

php bin/console debug:container --parameter=kernel.bundles --format=json | grep AcmeNewBundle

Note

Replace grep argument with your bundle’s proper name

In case if your bundle is registered and active next output(alike one) will be displayed in console after running the command

"AcmeNewBundle": "Acme\\Bundle\\NewBundle\\AcmeNewBundle",

That is all — your bundle is registered and active!

References