PHPackages                             tarasovich/symfony-yaml-merge-loader - 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. tarasovich/symfony-yaml-merge-loader

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

tarasovich/symfony-yaml-merge-loader
====================================

Possibility to merge imports in services.yaml

v1.0.0(4y ago)0120MITPHPPHP ^7.4 || ^8.0

Since Jul 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/tarasovich/symfony-yaml-merge-loader)[ Packagist](https://packagist.org/packages/tarasovich/symfony-yaml-merge-loader)[ RSS](/packages/tarasovich-symfony-yaml-merge-loader/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Symfony YAML merge loader
=========================

[](#symfony-yaml-merge-loader)

This is extension of **Symfony\\Component\\DependencyInjection\\Loader\\YamlFileLoader** adding possibility to merge imports in **services.yaml**:

```
# config/services.yaml
imports:
- { resource: 'services/*.yaml', merge: true }
```

Complication
------------

[](#complication)

From [Official symfony docs](https://symfony.com/doc/current/service_container/import.html#importing-configuration-with-imports):

> When loading a configuration file, Symfony loads first the imported files and then it processes the parameters and services defined in the file. If you use the default services.yaml configuration, the App\\ definition creates services for classes found in ../src/\*. If your imported file defines services for those classes too, they will be overridden.
>
> A possible solution for this is to add the classes and/or directories of the imported files in the exclude option of the App\\ definition. Another solution is to not use imports and add the service definitions in the same file, but after the App\\ definition to override it.“

With this extension you `don't need to exclude` imported services from `App\` definition.

Installation
------------

[](#installation)

### Get the extension using composer

[](#get-the-extension-using-composer)

Add YamlFileMergeLoader by running this command from the terminal at the root of your Symfony project:

```
composer require tarasovich/symfony-yaml-merge-loader
```

### Replace default loader

[](#replace-default-loader)

```
// src/Kernel.php (your kernel class may be defined in a different class/path)
namespace App;

use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Tarasovich\YamlFileMergeLoader;
// ...

class Kernel extends BaseKernel
{
    protected function getContainerLoader(ContainerInterface $container): LoaderInterface
    {
        /** @var ContainerBuilder $container */
        return YamlFileMergeLoader::replaceOriginalLoader(
            $container,
            parent::getContainerLoader($container),
            $this->getEnvironment()
        );
    }
}
```

### Organize imports files

[](#organize-imports-files)

Move some services and/or parameters definitions into other file, eg:

```
# config/services/hello_word.yaml
parameters:
  app.hello_word.text: 'Hello World!'

services:
  _defaults:
    autowire: true
    autoconfigure: true

  App\Service\HelloWordService:
    arguments:
      $defaultText: '%app.hello_word.text%'
```

Import resource to your services.yaml with `merge: true` option.

```
# config/services.yaml
imports:
- { resource: 'services/*.yaml', merge: true }

services:
  _defaults:
    autowire: true
    autoconfigure: true

  App\:
    resource: '../src/'
    exclude:
      - '../src/DependencyInjection/'
      - '../src/Entity/'
      - '../src/Kernel.php'
      - '../src/Tests/'
```

### That was it!

[](#that-was-it)

Now your `App\Service\HelloWordService` will be not overridden with the `App\` definition from `config/services.yaml`.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1460d ago

### Community

Maintainers

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

---

Top Contributors

[![tarasovich](https://avatars.githubusercontent.com/u/4404712?v=4)](https://github.com/tarasovich "tarasovich (4 commits)")

### Embed Badge

![Health badge](/badges/tarasovich-symfony-yaml-merge-loader/health.svg)

```
[![Health](https://phpackages.com/badges/tarasovich-symfony-yaml-merge-loader/health.svg)](https://phpackages.com/packages/tarasovich-symfony-yaml-merge-loader)
```

PHPackages © 2026

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