Documentation Home »Developer Cookbook »Application Framework Reciepes »How to Create a New Bundle
3.0 version
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 2.6

How to Create a New Bundle

To create a new bundle, you first need to specify a name and a namespace for it. Symfony framework provides best practices for bundle structure and bundle name and we highly recommend to follow them.

As an illustration, let us create AcmeNewBundle and put it under the Acme\Bundle\NewBundle namespace 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
{
}

This is basically a regular Symfony bundle. The only difference is in the way it is enabled.

Enable a Bundle

To enable the bundle:

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

    :linenos:
    
    # 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 the required bundles.

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

    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 the production environment, use the –env=prod parameter with the command.

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

Yes No
ssossossossosso