Skip over navigation
Documentation
You are currently viewing documentation for version 3.0 which is not a long-term support release. The latest long-term support release is version 1.6

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 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.

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:

../../../_images/dashboard.png

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

../../../_images/profiler.png

That is all — your bundle is registered and active!

Browse maintained versions:3.01.6

You will be redirected to [title]. Would you like to continue?

Yes No
sso for www.magecore.comsso for oroinc.desso for oroinc.fr
Back to top