PHPackages                             dhii/services-interface - 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. dhii/services-interface

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

dhii/services-interface
=======================

Interfaces for services compatible with Service Provider spec

0.1.x-dev(5y ago)035MITPHPPHP ^7.1 | ^8.0

Since Mar 15Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Dhii/services-interface)[ Packagist](https://packagist.org/packages/dhii/services-interface)[ RSS](/packages/dhii-services-interface/feed)WikiDiscussions 0.1.x Synced 1w ago

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

Dhii - Services Interface
=========================

[](#dhii---services-interface)

[![Continuous Integration](https://github.com/Dhii/services-interface/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/Dhii/services-interface/actions/workflows/continuous-integration.yml)[![Latest Stable Version](https://camo.githubusercontent.com/c1c4a6d1944fadf6c06650ce6f58dfad797a0b6526e2d8ab1efa9688cf677d4a/68747470733a2f2f706f7365722e707567782e6f72672f646869692f73657276696365732d696e746572666163652f76)](//packagist.org/packages/dhii/services-interface)[![Latest Unstable Version](https://camo.githubusercontent.com/3dc00564e4f06c2ed700a57c55f32fcba979b4c08470a21faad0847ae53f7f95/68747470733a2f2f706f7365722e707567782e6f72672f646869692f73657276696365732d696e746572666163652f762f756e737461626c65)](//packagist.org/packages/dhii/services-interface)

Interfaces for services compatible with [Service Provider](https://github.com/container-interop/service-provider) spec.

Details
-------

[](#details)

Use this interface to enhance your services, such that a dependency graph can be built. This paves the way for many features, including:

1. Visualization of a dependency graph of all application services.
2. Notification if a dependency is unfulfilled.
3. Suggestion of module packages that may fulfill unmet dependencies.

Use together with [`dhii/services`](https://github.com/Dhii/services) to enhance your services with convenient shorthands and type information.

Rationale
---------

[](#rationale)

The current signature of a service is just a callable of form `(ContainerInterface $c) => mixed`. This describes the service itself, and allows it to draw dependencies from the container. However, in order to know what other services are being used by any particular service definition, that definition must first be invoked. This means that as things currently are, it is not possible to build a map of all service relationships without actually executing them all.

The solution is to make services aware of and able to expose the names of other services that it depends on. This way, it is possible to make quite a uniform algorithm that can record all of these relationships, and and build a complete graph of all services and their dependencies. This opens up new possibilities for detection and automation.

An implementation such as [`Factory`](https://github.com/Dhii/services/blob/0.1.x/src/Factory.php) can declare its dependencies, and automatically resolve them before passing them to the service definition, making it possible to describe the types that the dependencies are expected to be. This also cuts on the amount of code to be written, removing not only type checks/assertions, but also the calls to `$c->get()`. At the same time, this approach re-enforces strictness, because a service definition no longer has the choice of retrieving or not retrieving its dependencies: all dependencies are declared and necessarily resolved before the definition has a chance to do anything. This makes graphs more stable, and creates less opportunity for hidden dependencies that may not show otherwise, such as if simply recording all service names retrieved from the container.

The `withDependencies()` method enables [multi-boxing](https://github.com/Dhii/services#multi-boxing), which allows the same service provider to be re-used multiple times in the same application - perhaps with different prefixes. This avoids not only the need for manual re-declaration of already defined services, but also has the potential for solving the service name collision problem, and it's no longer necessary to come up with clever prefixes for service names *in providers*, but shifts a part of the responsibility to the application. This is good, because it further re-enforces the notion that the application is in control - similarly to how the application decides which services override which, how the providers are discovered and loaded, etc.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Every ~0 days

Total

2

Last Release

1890d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1894e91b32c9f80d8f30a42d360af6983a507f1cf2c621b7c9a0a0de14e011c5?d=identicon)[XedinUnknown](/maintainers/XedinUnknown)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dhii-services-interface/health.svg)

```
[![Health](https://phpackages.com/badges/dhii-services-interface/health.svg)](https://phpackages.com/packages/dhii-services-interface)
```

###  Alternatives

[lunetics/timezone-bundle

A Bundle for detecting the timezone

2641.9k](/packages/lunetics-timezone-bundle)[amirbagh75/smsir-php

Unofficial sms.ir PHP Package

181.2k](/packages/amirbagh75-smsir-php)

PHPackages © 2026

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