PHPackages                             matthiasnoback/symfony-bundle-plugins - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. matthiasnoback/symfony-bundle-plugins

ActiveLibrary

matthiasnoback/symfony-bundle-plugins
=====================================

Allow Symfony bundles to have plugins

v1.1.1(10y ago)598.1k82MITPHPPHP &gt;=5.3

Since Jul 6Pushed 8y ago8 watchersCompare

[ Source](https://github.com/matthiasnoback/symfony-bundle-plugins)[ Packagist](https://packagist.org/packages/matthiasnoback/symfony-bundle-plugins)[ Docs](http://github.com/matthiasnoback/symfony-bundle-plugins)[ RSS](/packages/matthiasnoback-symfony-bundle-plugins/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (4)Used By (2)

Symfony Bundle Plugins
======================

[](#symfony-bundle-plugins)

By Matthias Noback

[![Build Status](https://camo.githubusercontent.com/ae479b0aff6c2e854043faadcba89ac628d17734dd41fb43d9569afd7a33e944/68747470733a2f2f7472617669732d63692e6f72672f6d617474686961736e6f6261636b2f73796d666f6e792d62756e646c652d706c7567696e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/matthiasnoback/symfony-bundle-plugins) [![Coverage Status](https://camo.githubusercontent.com/f5d70646489044725804e750ee59615e02e19c9cb0ab641e9306edcfbc626a53/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6d617474686961736e6f6261636b2f73796d666f6e792d62756e646c652d706c7567696e732f62616467652e737667)](https://coveralls.io/r/matthiasnoback/symfony-bundle-plugins)

This package helps you create extensible bundles, by introducing a plugin system for bundles. Each bundle plugin can define its own services and configuration. This basically makes your bundles conform to the open/closed principle.

Setup
-----

[](#setup)

Install this library in your project by running

```
composer require matthiasnoback/symfony-bundle-plugins

```

Example
-------

[](#example)

First, your bundle should extend `BundleWithPlugins`. You need to implement the `getAlias` method. It should return the name of your bundle's configuration key (as it will be used in `config.yml` for instance).

```
use Matthias\BundlePlugins\BundleWithPlugins;

class DemoBundle extends BundleWithPlugins
{
    protected function getAlias()
    {
        return 'demo';
    }
}
```

Each plugin for the bundle should implement `BundlePlugin`:

```
use Matthias\BundlePlugins\BundlePlugin;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

class FooPlugin implements BundlePlugin
{
    public function name()
    {
        return 'foo';
    }

    public function load(
        array $pluginConfiguration,
        ContainerBuilder $container
    ) {
        // load specific service definitions for this plugin,
        // just like you would do in a bundle extension

        $loader = new YamlFileLoader($container, new FileLocator(__DIR__));
        $loader->load('foo.yml');

        // $pluginConfiguration contains just the values that are relevant
        // for this plugin
    }

    public function addConfiguration(ArrayNodeDefinition $pluginNode)
    {
        // add plugin-specific configuration nodes,
        // just like you would do in a bundle extension

        $pluginNode
            ->children()
                ->scalarNode('foo')
                ->isRequired()
            ->end();
    }
}
```

When instantiating this bundle in your `AppKernel` class, you can provide any number of `BundlePlugin` instances:

```
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        return array(
            ...,
            new DemoBundle(array(new FooPlugin()))
        );
    }
}
```

If some of the plugins are required, just introduce a `CorePlugin` and make sure it is always registered by overriding your bundle's `alwaysRegisteredPlugins()` method:

```
class DemoBundle
{
    ...

    protected function alwaysRegisteredPlugins()
    {
        return array(new CorePlugin());
    }
}
```

Register compiler passes
------------------------

[](#register-compiler-passes)

When a bundle plugin needs to register a compiler pass, it can do so in its `build()` method.

```
class FooPlugin implements BundlePlugin
{
    ...

    public function build(ContainerBuilder $container)
    {
        $container->addCompilerPass(...);
    }
}
```

Booting a plugin
----------------

[](#booting-a-plugin)

Whenever the main bundle is booted, plugins are allowed to do some runtime initialization as well. They can do this in their `boot()` method. At that time, the fully initialized service container is available:

```
class FooPlugin implements BundlePlugin
{
    ...

    public function boot(ContainerInterface $container)
    {
        // runtime initialization (will run when the kernel itself is
        // booted)
    }
}
```

Simple plugins
--------------

[](#simple-plugins)

If your plugin is quite simple (i.e. only needs a `load()` method), just make the plugin class extend `SimpleBundlePlugin` which contains stub implementations for the interface methods that you won't need.

Thanks
------

[](#thanks)

To [@dennisdegreef](https://github.com/dennisdegreef) for reviving the test suite of this project.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~99 days

Total

3

Last Release

3772d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1193078?v=4)[Matthias Noback](/maintainers/matthiasnoback)[@matthiasnoback](https://github.com/matthiasnoback)

---

Top Contributors

[![matthiasnoback](https://avatars.githubusercontent.com/u/1193078?v=4)](https://github.com/matthiasnoback "matthiasnoback (15 commits)")[![Spomky](https://avatars.githubusercontent.com/u/1091072?v=4)](https://github.com/Spomky "Spomky (2 commits)")[![dennisdegreef](https://avatars.githubusercontent.com/u/361905?v=4)](https://github.com/dennisdegreef "dennisdegreef (1 commits)")[![gregurco](https://avatars.githubusercontent.com/u/4052904?v=4)](https://github.com/gregurco "gregurco (1 commits)")[![rskuipers](https://avatars.githubusercontent.com/u/1918518?v=4)](https://github.com/rskuipers "rskuipers (1 commits)")

---

Tags

pluginsymfonybundle

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/matthiasnoback-symfony-bundle-plugins/health.svg)

```
[![Health](https://phpackages.com/badges/matthiasnoback-symfony-bundle-plugins/health.svg)](https://phpackages.com/packages/matthiasnoback-symfony-bundle-plugins)
```

###  Alternatives

[pentatrion/vite-bundle

Vite integration for your Symfony app

2755.3M13](/packages/pentatrion-vite-bundle)[kreait/firebase-bundle

Symfony Bundle for the Firebase Admin SDK

1534.7M2](/packages/kreait-firebase-bundle)[sensiolabs/gotenberg-bundle

A Symfony bundle that provides seamless integration with Gotenberg for generating PDFs and screenshots from various sources (HTML, Markdown, Office documents, URLs) with a clean, builder-based API.

210210.4k2](/packages/sensiolabs-gotenberg-bundle)[spomky-labs/pwa-bundle

Progressive Web App Manifest Generator Bundle for Symfony.

6144.4k1](/packages/spomky-labs-pwa-bundle)[cmsig/seal-symfony-bundle

An integration of CMS-IG SEAL search abstraction into Symfony Framework.

15195.8k5](/packages/cmsig-seal-symfony-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
