You are browsing the documentation for version 4.1 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:

 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:

         - 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


    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


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!

Generate an Installer for a Bundle

When you have implemented new entities, you want to be sure that upon installing the application, the entities are added to the database. For this, you need to create an installer. You can do it manually, however, it is more convenient to use a dump of the database as a template.

To create an installer for AcmeBundle:

  1. Clear the application cache:

    1bin/console cache:clear
  2. Apply the changes that you defined in your code to the database:

    1bin/console doctrine:schema:update
  3. Generate an installer and save it to the AcmeBundleInstaller.php:

    1bin/console oro:migration:dump --bundle=AcmeBundle > AcmeBundleInstaller.php


    The generated installer may contain a lot of excessive information as the same database table might contain options related to different bundles and entities while the generator has no option to distinguish which entity ‘has added’ particular options. Delete the information unrelated to your entities from the output file.

Move AcmeBundleInstall.php to the AcmeBundle/Migrations/Schema directory.

  1. Reinstall your application instance.

  2. Check that the database is synced with your code:

    1bin/console doctrine:schema:update --dump-sql

    If the database is successfully synchronized, you will see the following message:

    1Nothing to update - your database is already in sync with the current entity metadata.