PHPackages                             drunomics/service-utils - 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. drunomics/service-utils

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

drunomics/service-utils
=======================

Provides setter injection traits in order to ease dependency injection of services.

11.0.0(7mo ago)3190.0k↓19.3%44GPL-2.0+PHPCI failing

Since Aug 28Pushed 3mo ago6 watchersCompare

[ Source](https://github.com/drunomics/service-utils)[ Packagist](https://packagist.org/packages/drunomics/service-utils)[ Docs](https://github.com/drunomics/service-utils)[ RSS](/packages/drunomics-service-utils/feed)WikiDiscussions 11.x Synced 1w ago

READMEChangelog (10)Dependencies (5)Versions (35)Used By (4)

Service Utils
=============

[](#service-utils)

(c) 2017-2025 drunomics GmbH

[![PHPUnit and code style checks](https://github.com/drunomics/service-utils/actions/workflows/PHPUnit-CodeStyle.yml/badge.svg)](https://github.com/drunomics/service-utils/actions/workflows/PHPUnit-CodeStyle.yml)

Provides setter injection traits in order to ease dependency injection of services.

Versions
--------

[](#versions)

Major version numbers match Drupal core compatibility, e.g.

```
 2.x -> Drupal 8.2.x
 3.x -> Drupal 8.3.x
 4.x -> Drupal 8.4.x
 5.x -> Drupal 8.5.x
 6.x -> Drupal 8.6.x
 7.x -> Drupal 8.7.x
 8.x -> Drupal 8.8.x
 9.x -> Drupal 8.9.x
 9.1.x -> Drupal 9.1.x
 9.2.x -> Drupal 9.2.x
 9.3.x -> Drupal 9.3.x
 9.4.x -> Drupal 9.4.x
 10.x -> Drupal 10.x
 11.x -> Drupal 11.x

```

Scope
-----

[](#scope)

This covers traits for services that are missing from core or contrib modules.

Usage
-----

[](#usage)

- Install the package via `composer require drunomics/service-utils`
- Just "use" the trait for the service you want to use. The trait provides a suiting getter; e.g., `getEntityTypeManager()`.

Adding a missing trait
----------------------

[](#adding-a-missing-trait)

- Just add new trait and add it in the respective namespace. The namespace should match the namespace of the service, but start with \\drunomics\\ServiceUtils instead of \\Drupal.
- Every trait needs a respective test case. You can simply copy an existing test case and adapt it as necessary.
- Run tests to ensure everything works as needed and file a PR for your !
- If your trait covers a contrib module, make sure the contrib module is added as dev-dependency, so its classes are there for running tests.

Running tests
-------------

[](#running-tests)

- Just clone the project and run the following commands from the project directory:

```
   composer install
   ./vendor/bin/phpunit # or use the shortcut
   composer test

```

Coding style
------------

[](#coding-style)

To check the coding style for the project's custom code, run PHP code sniffer:

```
composer cs

```

To automatically fix the coding style errors (as far as possible), run the PHP code beautifier:

```
composer cbf

```

FAQ
---

[](#faq)

- Why are the traits not added to the upstream source (core or contrib modules) instead?

    This would be the best option, but results in a worse developer experience (DX) while patches are not committed. The goal of this package is to make dependency injection almost as quick as calling out to \\Drupal::container(), thus adding in a patch every time a dependency is needed is taking too long and so results in a worse DX.

    The suggested workflow is to quickly add missing traits to this package, so they are immediately available for everyone's use. On a regular basis, patches for traits should be filed against upstream projects in order to improve them and deprecate this package in the long term. Once those patches landed in new upstream releases, the service-utils usages could be replaced and the package can be safely dropped from a project.
- Why is this no project on drupal.org?

    Because drupal.org has no project type for composer packages and using Github with Travis for tests is convenient.

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance71

Regular maintenance activity

Popularity39

Limited adoption so far

Community26

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~71 days

Recently: every ~40 days

Total

29

Last Release

118d ago

Major Versions

9.3.x-dev → 10.0.02022-07-07

9.4.1 → 10.1.02022-10-11

9.5.0 → 10.1.12023-11-07

10.x-dev → 11.0.02025-10-28

11.x-dev → 12.x-dev2026-02-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/132232?v=4)[Wolfgang Ziegler](/maintainers/fago)[@fago](https://github.com/fago)

---

Top Contributors

[![fago](https://avatars.githubusercontent.com/u/132232?v=4)](https://github.com/fago "fago (27 commits)")[![petarbasic](https://avatars.githubusercontent.com/u/52317999?v=4)](https://github.com/petarbasic "petarbasic (17 commits)")[![mostepaniukvm](https://avatars.githubusercontent.com/u/15616007?v=4)](https://github.com/mostepaniukvm "mostepaniukvm (11 commits)")[![mbm80](https://avatars.githubusercontent.com/u/19147241?v=4)](https://github.com/mbm80 "mbm80 (6 commits)")[![pagachdrunomics](https://avatars.githubusercontent.com/u/45197243?v=4)](https://github.com/pagachdrunomics "pagachdrunomics (5 commits)")[![StavoveiC](https://avatars.githubusercontent.com/u/94967064?v=4)](https://github.com/StavoveiC "StavoveiC (2 commits)")[![vasike](https://avatars.githubusercontent.com/u/514846?v=4)](https://github.com/vasike "vasike (2 commits)")[![ivangrozni](https://avatars.githubusercontent.com/u/3587288?v=4)](https://github.com/ivangrozni "ivangrozni (1 commits)")[![peterserfozo](https://avatars.githubusercontent.com/u/22172388?v=4)](https://github.com/peterserfozo "peterserfozo (1 commits)")

---

Tags

dependency-injectiondrupal-8servicesdependency-injectiondrupal

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/drunomics-service-utils/health.svg)

```
[![Health](https://phpackages.com/badges/drunomics-service-utils/health.svg)](https://phpackages.com/packages/drunomics-service-utils)
```

###  Alternatives

[php-di/invoker

Generic and extensible callable invoker

26862.3M66](/packages/php-di-invoker)[lullabot/amp

A set of useful classes and utilities to convert html to AMP html (See https://www.ampproject.org/)

3793.0M10](/packages/lullabot-amp)[level-2/dice

A minimalist Dependency injection container (DIC) for PHP. Please note: 3.0+ is only compatible with PHP 7.0. The 2.0 branch is compatbile with PHP 5.6.

437773.0k19](/packages/level-2-dice)[drupal/core-composer-scaffold

A flexible Composer project scaffold builder.

5344.1M525](/packages/drupal-core-composer-scaffold)[mnsami/composer-custom-directory-installer

A composer plugin, to help install packages of different types in custom paths.

1465.3M59](/packages/mnsami-composer-custom-directory-installer)[drupal/core-project-message

Adds a message after Composer installation.

2124.0M192](/packages/drupal-core-project-message)

PHPackages © 2026

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