ssossossosso
Documentation Home »Developer Guide »Customizing Oro Features »How to Create New Bundle
current version

How to Create New Bundle

Used application: OroPlatform 1.7

New bundle can be created either manually, or automatically using standard Symfony console command.

Create 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:

1
2
3
4
5
6
7
8
9
<?php
// 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 bundle).

Enable 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:

    1
    2
    3
    # 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:

    1
    2
    user@host:/var/www/vhosts/platform-application$ php app/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.

Now open the application user interface in development mode (use the link http://<oro-application-base-url>/app_dev.php/) and click the Symfony profiler config icon:

Here you can find your new bundle in the list of active bundles:

That is all — your bundle is registered and active!

Browse maintained versions:
current1.4