PHPackages                             bit3/service-aware-bundle - 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. [Framework](/categories/framework)
4. /
5. bit3/service-aware-bundle

AbandonedArchivedLibrary[Framework](/categories/framework)

bit3/service-aware-bundle
=========================

Automated service injection for symfony.

374PHP

Since Sep 25Pushed 9y ago1 watchersCompare

[ Source](https://github.com/bit3/service-aware-bundle)[ Packagist](https://packagist.org/packages/bit3/service-aware-bundle)[ RSS](/packages/bit3-service-aware-bundle/feed)WikiDiscussions develop Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

[![Version](https://camo.githubusercontent.com/859888e883d2010dd32c17d8fa598a2b917fd06c730d3f4ad782c4fd0a6daa57/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626974332f736572766963652d61776172652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bit3/service-aware-bundle)[![Stable Build Status](https://camo.githubusercontent.com/6c453f46756fc6e4a5b12005a78af29e460d1189a4c0f341e458ad8a869c7387/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f626974332f736572766963652d61776172652d62756e646c652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bit3/service-aware-bundle)[![Upstream Build Status](https://camo.githubusercontent.com/97b2a6bb32a015264a534bdf49323cb615cc027094011b3b01d7b824db4c29f9/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f626974332f736572766963652d61776172652d62756e646c652f646576656c6f702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bit3/service-aware-bundle)[![License](https://camo.githubusercontent.com/1ccb663bdad1569d6f7a91c22878d38ef07b0904c7bfe50a98eb67577ed0b252/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f626974332f736572766963652d61776172652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://github.com/bit3/service-aware-bundle/blob/master/LICENSE)[![Downloads](https://camo.githubusercontent.com/51a4fa665e1972c4f8f9f8395823ae4603aa28dc5c74c2f225810ddd078027d2/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626974332f736572766963652d61776172652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bit3/service-aware-bundle)

Service Aware Bundle
====================

[](#service-aware-bundle)

Create services with dependencies may result in a lot of duplicated meta code. For example:

```
service:
    service_foo:
        class: Acme\DemoBundle\Service\Foo
        calls:
            - [setEntityManager, [@doctrine.orm.default_entity_manager]]
            - [setTranslator, [@translator]]

    service_bar:
        class: Acme\DemoBundle\Service\Bar
        calls:
            - [setTranslator, [@translator]]
            - [setValidator, [@validator]]

    service_zap:
        class: Acme\DemoBundle\Service\Zap
        calls:
            - [setEntityManager, [@doctrine.orm.default_entity_manager]]
            - [setTranslator, [@translator]]
            - [setValidator, [@validator]]
```

And in the classes:

```
namespace Acme\DemoBundle\Service;

class Foo {
    private $entityManager;
    private $translator;

    public function setEntityManager($entityManager) {
        $this->entityManager = $entityManager;
    }

    public function setTranslator($translator) {
        $this->translator = $translator;
    }
}
```

```
namespace Acme\DemoBundle\Service;

class Bar {
    private $translator;
    private $validator;

    public function setTranslator($translator) {
        $this->translator = $translator;
    }

    public function setValidator($validator) {
        $this->validator = $validator;
    }
}
```

```
namespace Acme\DemoBundle\Service;

class Zap {
    private $entityManager;
    private $translator;
    private $validator;

    public function setEntityManager($entityManager) {
        $this->entityManager = $entityManager;
    }

    public function setTranslator($translator) {
        $this->translator = $translator;
    }

    public function setValidator($validator) {
        $this->validator = $validator;
    }
}
```

This bundle help you to avoid to define all the setters calls and implementations. It provide a lot of `*Aware` interfaces, abstract base classes and traits.

How to use
----------

[](#how-to-use)

Using the bundle is simple, you only need to implement the interfaces and remove the setter calls from the `services.yml`.

```
service:
    service_foo:
        class: Acme\DemoBundle\Service\Foo

    service_bar:
        class: Acme\DemoBundle\Service\Bar

    service_zap:
        class: Acme\DemoBundle\Service\Zap
```

And in the classes:

```
namespace Acme\DemoBundle\Service;

use Bit3\Symfony\ServiceAwareBundle\Doctrine\DoctrineBundle\EntityManagerAwareInterface;
use Bit3\Symfony\ServiceAwareBundle\Doctrine\DoctrineBundle\EntityManagerAwareTrait;
use Bit3\Symfony\ServiceAwareBundle\Symfony\FrameworkBundle\Translator\TranslatorAwareInterface;
use Bit3\Symfony\ServiceAwareBundle\Symfony\FrameworkBundle\Translator\TranslatorAwareTrait;

class Foo implements EntityManagerAwareInterface, TranslatorAwareInterface {
    use EntityManagerAwareTrait;
    use TranslatorAwareTrait;
}
```

```
namespace Acme\DemoBundle\Service;

use Bit3\Symfony\ServiceAwareBundle\Symfony\FrameworkBundle\Translator\TranslatorAwareInterface;
use Bit3\Symfony\ServiceAwareBundle\Symfony\FrameworkBundle\Translator\TranslatorAwareTrait;
use Bit3\Symfony\ServiceAwareBundle\Symfony\FrameworkBundle\Validator\ValidatorAwareInterface;
use Bit3\Symfony\ServiceAwareBundle\Symfony\FrameworkBundle\Validator\ValidatorAwareTrait;

class Bar implements EntityManagerAwareInterface, TranslatorAwareInterface, ValidatorAwareInterface {
    use TranslatorAwareTrait;
    use ValidatorAwareTrait;
}
```

```
namespace Acme\DemoBundle\Service;

use Bit3\Symfony\ServiceAwareBundle\Doctrine\DoctrineBundle\EntityManagerAwareInterface;
use Bit3\Symfony\ServiceAwareBundle\Doctrine\DoctrineBundle\EntityManagerAwareTrait;
use Bit3\Symfony\ServiceAwareBundle\Symfony\FrameworkBundle\Translator\TranslatorAwareInterface;
use Bit3\Symfony\ServiceAwareBundle\Symfony\FrameworkBundle\Translator\TranslatorAwareTrait;
use Bit3\Symfony\ServiceAwareBundle\Symfony\FrameworkBundle\Validator\ValidatorAwareInterface;
use Bit3\Symfony\ServiceAwareBundle\Symfony\FrameworkBundle\Validator\ValidatorAwareTrait;

class Zap implements EntityManagerAwareInterface, TranslatorAwareInterface, ValidatorAwareInterface {
    use EntityManagerAwareTrait;
    use TranslatorAwareTrait;
    use ValidatorAwareTrait;
}
```

Pretty simple, huh?

Define service aware's
----------------------

[](#define-service-awares)

You can define your own service aware interfaces in your `app/config/config.yml`.

```
service_aware:
  services:
    acme_demo_bundle.services.service_foo:
      interface: "Acme\DemoBundle\Service\FooAwareInterface"
      method:    "setServiceFoo"
      service:   "acme_demo_bundle.service_foo"
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e61f74ea186c1e79e072b2974ccdeef39414730476d5a8adac501eb9449b2a3?d=identicon)[tril](/maintainers/tril)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/bit3-service-aware-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/bit3-service-aware-bundle/health.svg)](https://phpackages.com/packages/bit3-service-aware-bundle)
```

###  Alternatives

[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k39.6M299](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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