Important

You are browsing documentation for version 5.1 of OroCommerce, supported until March 2027. Read the documentation for the latest LTS version 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, specify the name and namespace of your bundle. The Symfony framework already provides best practices for bundle structure and bundle name, and we recommend following them.

Suppose you want to create the AcmeDemoBundle under the namespace Acme\Bundle\DemoBundle in the /src directory. Create the corresponding directory structure and the bundle file with the following content:

src/Acme/Bundle/DemoBundle/AcmeDemoBundle.php 
namespace Acme\Bundle\DemoBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AcmeDemoBundle extends Bundle
{
}

This is a regular Symfony bundle. The only difference is how you enable it (see Enable a Bundle).

Create a Bundle Service Container Extension 

To load configuration files, create a Service Container Extension. See Symfony Configuration Files

src/Acme/Bundle/DemoBundle/DependencyInjection/AcmeDemoExtension.php 
namespace Acme\Bundle\DemoBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class AcmeDemoExtension extends Extension
{
    public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        // register services configuration
        $loader->load('services.yml');
        // register other configurations in the same way
    }
}

Create a basic Resources/config/services.yml to define service parameters. See Symfony Service Parameters

src/Acme/Bundle/DemoBundle/Resources/config/services.yml 
 services:

Enable a Bundle 

You now have all the files required to enable the new bundle. To enable it:

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

src/Acme/Bundle/DemoBundle/Resources/config/oro/bundles.yml 
bundles:
    - { name: Acme\Bundle\DemoBundle\AcmeDemoBundle, priority: 255 }

This file provides a list of bundles to register. All such files are automatically parsed to load the required bundles.

  1. Regenerate the application cache using 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, use parameter --env=prod with the command.

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

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

    Note

    Replace grep argument with your bundle’s proper name

  3. When your bundle is registered and active, the command displays output similar to the following:

    "AcmeDemoBundle": "Acme\\Bundle\\DemoBundle\\AcmeDemoBundle",
    

References