PHPackages                             mmoreram/symfony-bundle-dependencies - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mmoreram/symfony-bundle-dependencies

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mmoreram/symfony-bundle-dependencies
====================================

Dependencies resolver for Symfony Bundles

2.3.0(5y ago)57191.7k↓39%3[3 issues](https://github.com/mmoreram/symfony-bundle-dependencies/issues)20MITPHPPHP ^7.1|^8.0

Since Nov 23Pushed 5y ago4 watchersCompare

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

READMEChangelog (7)Dependencies (6)Versions (8)Used By (20)

Symfony Bundle Dependencies
===========================

[](#symfony-bundle-dependencies)

[![Build Status](https://camo.githubusercontent.com/b4c7c0f0234d96a74d244bc50d6a95bb5eb9714895220a83a5598cfe754eb232/68747470733a2f2f7472617669732d63692e6f72672f6d6d6f726572616d2f73796d666f6e792d62756e646c652d646570656e64656e636965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mmoreram/symfony-bundle-dependencies)

> The minimum requirements of this bundle is **PHP 7.1** and **Symfony 3.2**because the bundle is using features on both versions. If you're not using them yet, I encourage you to do it.

This package provides a very simple way of adding dependencies between Symfony Bundles. Composer defines these definitions in a very soft layer, only downloading these dependent packages. Bundles should as well force other Bundles to be instanced in the application to comply with Dependency Injection dependencies.

- [For your bundle](#for-your-bundle)
- [For your kernel](#for-your-kernel)
- [Performance](#performance)
- [The order](#the-order)

For your Bundle
---------------

[](#for-your-bundle)

If you want your bundles to provide this feature, then is as simple as make your bundles implement an interface. That simple.

Take in account that this addition will only provide compatibility with projects using this project, and will not affect anyway projects not using it.

```
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Mmoreram\SymfonyBundleDependencies\DependentBundleInterface;

/**
 * My Bundle
 */
class MyBundle extends Bundle implements DependentBundleInterface
{
    /**
     * Create instance of current bundle, and return dependent bundle namespaces
     *
     * @return array Bundle instances
     */
    public static function getBundleDependencies(KernelInterface $kernel)
    {
        return [
            'Another\Bundle\AnotherBundle',
            'My\Great\Bundle\MyGreatBundle',
            // ...
        ];
    }
}
```

Maybe one of your bundle dependencies need an specific value in the constructor. Well, this is a very very weird case, and you should definitely avoid it, but you can do it by adding the instance instead of the namespace.

```
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Mmoreram\SymfonyBundleDependencies\DependentBundleInterface;

/**
 * My Bundle
 */
class MyBundle extends Bundle implements DependentBundleInterface
{
    /**
     * Create instance of current bundle, and return dependent bundle namespaces
     *
     * @return array Bundle instances
     */
    public static function getBundleDependencies(KernelInterface $kernel)
    {
        return [
            'Another\Bundle\AnotherBundle',
            'My\Great\Bundle\MyGreatBundle',
            new \Even\Another\Bundle\EvenAnotherBundle('some-value'),
        ];
    }
}
```

By default, all bundles defined as their namespace are instanced with the kernel object as first parameter, so doing something like that doesn't really have sense at all.

```
use Mmoreram\SymfonyBundleDependencies\DependentBundleInterface;

/**
 * My Bundle
 */
class MyBundle implements DependentBundleInterface
{
    /**
     * Create instance of current bundle, and return dependent bundle namespaces
     *
     * @return array Bundle instances
     */
    public static function getBundleDependencies(KernelInterface $kernel)
    {
        return [
            new \Even\Another\Bundle\EvenAnotherBundle($this),
        ];
    }
}
```

As you will see later, using instances instead of names will remove the possibility of using cache in the final project.

For your Kernel
---------------

[](#for-your-kernel)

In your project, you should be able to resolve all these dependencies. This is why this package offers you as well a way of doing that in your kernel.

```
use Symfony\Component\HttpKernel\Kernel;
use Mmoreram\SymfonyBundleDependencies\BundleDependenciesResolver;

/**
 * Class AppKernel
 */
class AppKernel extends Kernel
{
    use BundleDependenciesResolver;

    /**
     * Register application bundles
     *
     * @return array Array of bundles instances
     */
    public function registerBundles()
    {
        return $this->getBundleInstances([
            '\My\Bundle\MyBundle',
        ]);
    }
}
```

In that case, you can pass as well instances of bundles instead of strings.

```
use Symfony\Component\HttpKernel\Kernel;
use Mmoreram\SymfonyBundleDependencies\BundleDependenciesResolver;

/**
 * Class AppKernel
 */
class AppKernel extends Kernel
{
    use BundleDependenciesResolver;

    /**
     * Register application bundles
     *
     * @return array Array of bundles instances
     */
    public function registerBundles()
    {
        return $this->getBundleInstances([
            new \My\Bundle\MyBundle($this),
        ]);
    }
}
```

Performance
-----------

[](#performance)

As you may see, resolving dependencies can penalize a lot your website performance. Each time your Kernel is booted, all dependencies are resolved once and again, and this has no sense at all.

This package offers you as well a cache layer, reducing to 0 from the second time your Kernel is booted and until your next deployment (cache file is stored in Kernel cache folder).

One simple change to your code. That easy.

```
use Mmoreram\SymfonyBundleDependencies\CachedBundleDependenciesResolver;

/**
 * Class AppKernel
 */
class AppKernel
{
    use CachedBundleDependenciesResolver;

    /**
     * Register application bundles
     *
     * @return array Array of bundles instances
     */
    public function registerBundles()
    {
        return $this->getBundleInstances([
            '\My\Bundle\MyBundle',
        ]);
    }
}
```

Caching your bundle dependencies resolution can only be used when all dependencies are defined as strings instead of instances.

This library assumes that, as soon as something changes in your project that can change the dependencies file, you will remove cache. Just take it in account.

The order
---------

[](#the-order)

Of course, the order matters. If two of your dependencies instantiate the same bundle with different parameters, then the first one to be defined will be the winner. In that case, if you want to explicitly define how a bundle must be instantiated even if other dependencies do, add this bundle at the beginning of your array.

```
use Symfony\Component\HttpKernel\Kernel;
use Mmoreram\SymfonyBundleDependencies\BundleDependenciesResolver;

/**
 * Class AppKernel
 */
class AppKernel extends Kernel
{
    use BundleDependenciesResolver;

    /**
     * Register application bundles
     *
     * @return array Array of bundles instances
     */
    public function registerBundles()
    {
        return $this->getBundleInstances([
            new \My\Bundle\MyBundle($this, true),
            'Another\Bundle\AnotherBundle',
            'My\Great\Bundle\MyGreatBundle',
        ]);
    }
}
```

This is also applied when defining the bundle dependencies.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 82.6% 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 ~316 days

Recently: every ~470 days

Total

7

Last Release

1932d ago

Major Versions

v1.1.1 → v2.0.02016-12-27

PHP version history (4 changes)v1.0.0PHP ^5.4|^7.0

v2.0.0PHP &gt;=7.1

2.2.0PHP ^7.1

2.3.0PHP ^7.1|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e8cb88fa6413489c9cdb77288a06ff94b4553aa497d8fc0ee1891576053f1306?d=identicon)[mmoreram](/maintainers/mmoreram)

---

Top Contributors

[![mmoreram](https://avatars.githubusercontent.com/u/521409?v=4)](https://github.com/mmoreram "mmoreram (19 commits)")[![phansys](https://avatars.githubusercontent.com/u/1231441?v=4)](https://github.com/phansys "phansys (2 commits)")[![javiereguiluz](https://avatars.githubusercontent.com/u/73419?v=4)](https://github.com/javiereguiluz "javiereguiluz (1 commits)")[![xphere](https://avatars.githubusercontent.com/u/170968?v=4)](https://github.com/xphere "xphere (1 commits)")

---

Tags

dependenciessymfonysymfony-bundlesymfonybundledependencies

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mmoreram-symfony-bundle-dependencies/health.svg)

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

###  Alternatives

[pentatrion/vite-bundle

Vite integration for your Symfony app

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

Feature toggle bundle on steroids.

283.8M](/packages/flagception-flagception-bundle)[spomky-labs/pwa-bundle

Progressive Web App Manifest Generator Bundle for Symfony.

6144.4k1](/packages/spomky-labs-pwa-bundle)[symfony-bundles/bundle-dependency

Symfony BundleDependency Component

19135.9k7](/packages/symfony-bundles-bundle-dependency)[sineflow/clamav

ClamAV PHP Client for Symfony

10168.5k](/packages/sineflow-clamav)[bornfreee/tactician-domain-events-bundle

Bundle to integrate Tactician Domain Events library with Symfony project

10138.6k](/packages/bornfreee-tactician-domain-events-bundle)

PHPackages © 2026

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