PHPackages                             ioc-interop/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. ioc-interop/interface

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

ioc-interop/interface
=====================

Interoperable IOC container interfaces for PHP.

1.x-dev(3mo ago)03622MITPHP

Since Feb 3Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/ioc-interop/interface)[ Packagist](https://packagist.org/packages/ioc-interop/interface)[ RSS](/packages/ioc-interop-interface/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (2)Used By (2)

Ioc-Interop Standard Interface Package
======================================

[](#ioc-interop-standard-interface-package)

Ioc-Interop provides an interoperable package of standard interfaces for inversion-of-control (IOC) service container functionality. It reflects, refines, and reconciles the common practices identified within [several pre-existing projects](./README-RESEARCH.md).

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [BCP 14](https://www.rfc-editor.org/info/bcp14) ([RFC 2119](https://datatracker.ietf.org/doc/html/rfc2119), [RFC 8174](https://datatracker.ietf.org/doc/html/rfc8174)).

Interfaces
----------

[](#interfaces)

This package defines the following interfaces:

- [*IocContainer*](#ioccontainer) affords obtaining services by name.
- [*IocContainerFactory*](#ioccontainerfactory) affords obtaining a new instance of [*IocContainer*](#ioccontainer).
- [*IocThrowable*](#iocthrowable) extends [*Throwable*](https://php.net/Throwable) to mark an [*Exception*](https://php.net/Exception) as IOC-related. It adds no class members.
- [*IocTypeAliases*](#ioctypealiases) defines PHPStan type aliases to aid static analysis.

### *IocContainer*

[](#ioccontainer)

[*IocContainer*](#ioccontainer) affords obtaining services by name.

- Notes:

    - **This interface does not afford service management.** The container will need to obtain services somehow, e.g. from a [Service-Interop](https://github.com/service-interop/interface)implementation.

#### *IocContainer* Methods

[](#ioccontainer-methods)

- ```
    public function hasService(ioc_service_name_string $serviceName) : bool;
    ```

    - Is the container able to return an instance of the `$serviceName`?
    - Notes:

        - **The logic for this method is expressly unspecified.** The ability check may accomplished by querying a service management subsystem, or by some other means.
- ```
    public function getService(
        ioc_service_name_string $serviceName,
    ) : ioc_service_object;
    ```

    - Returns an instance of the `$serviceName`.
    - Directives:

        - Implementations MUST throw [*IocThrowable*](#iocthrowable) if the container cannot return an instance of the `$serviceName`.
    - Notes:

        - **The logic for this method is expressly unspecified.** Retrieval may be accomplished via a service management subsystem, or by some other means.
        - **The returned instance may be new or shared.** The retrieval logic defines the service lifetime, not the container (per se) and not the caller requesting the service.

### *IocContainerFactory*

[](#ioccontainerfactory)

[*IocContainerFactory*](#ioccontainerfactory) affords obtaining a new instance of [*IocContainer*](#ioccontainer).

#### *IocContainerFactory* Methods

[](#ioccontainerfactory-methods)

- ```
    public function newContainer() : IocContainer;
    ```

    - Returns a new instance of [*IocContainer*](#ioccontainer).
    - Notes:

        - **Container instantiation logic is not specified.** Implementations might use providers, configuration files, attribute or annotation collection, or some other means to create and populate a container. Implementations might also choose to return a compiled or otherwise reconstituted container.

### *IocThrowable*

[](#iocthrowable)

[*IocThrowable*](#iocthrowable) extends [*Throwable*](https://php.net/Throwable) to mark an [*Exception*](https://php.net/Exception) as IOC-related. It adds no class members.

### *IocTypeAliases*

[](#ioctypealiases)

[*IocTypeAliases*](#ioctypealiases) defines PHPStan type aliases to aid static analysis.

- ```
    ioc_service_name_string class-string|string

    ```

    - A `class-string` or `string` name for a service.
- ```
    ioc_service_object ($serviceName is class-string ? T : object)

    ```

    - The service `object` for a given service name.

Implementations
---------------

[](#implementations)

- Directives:

    - Implementations MAY define additional class members not defined in these interfaces.
- Notes:

    - **Reference implementations** may be found at .

Q &amp; A
---------

[](#q--a)

### How is Ioc-Interop different from PSR-11?

[](#how-is-ioc-interop-different-from-psr-11)

[PSR-11](https://www.php-fig.org/psr/psr-11/) is an earlier recommendation that offers an interface to `get`items from a container, and to see if that container `has` a particular item.

Ioc-Interop is functionally almost identical to PSR-11. However, Ioc-Interop is intended to contain only services (`object`). PSR-11 is intended to contain anything (`mixed`).

Ioc-Interop also offers an [*IocContainerFactory*](#ioccontainerfactory) interface, whereas PSR-11 offers none.

### Is Ioc-Interop compatible with PSR-11?

[](#is-ioc-interop-compatible-with-psr-11)

No, in the sense that the method names, signatures, and intents are different.

Yes, in the sense that both may be implemented on the same class; the method names are different, and so are non-conflicting.

### Why does Ioc-Interop not afford service management?

[](#why-does-ioc-interop-not-afford-service-management)

Ioc-Interop is focused on the concerns around *obtaining* and *consuming*services. The affordances for *managing* and *producing* services are a set of separate concerns.

Earlier drafts of Ioc-Interop were much more expansive, including a resolver subsystem and a service management subsystem. These have been extracted to separate standards, each of which is dependent on Ioc-Interop:

- [Service-Interop](https://github.com/service-interop/interface)
- [Resolver-interop](https://github.com/resolver-interop/interface)

This separation helps to maintain a boundary between the needs of service consumers (afforded by Ioc-Interop) and service producers (afforded by [Service-Interop](https://github.com/service-interop/interface) and [Resolver-Interop](https://github.com/resolver-interop/interface)).

Note that Ioc-Interop is independent of [Service-Interop](https://github.com/service-interop/interface) and [Resolver-Interop](https://github.com/resolver-interop/interface). Ioc-Interop implementations can use them, or avoid them, as implementors see fit.

### Is [*IocContainer*](#ioccontainer) for Dependency Injection or is it a Service Locator?

[](#is-ioccontainer-for-dependency-injection-or-is-it-a-service-locator)

[*IocContainer*](#ioccontainer) acts a Service Locator only when it is used as a dependency in order to retrieve other dependencies from it.

### Why does [*IocContainer*](#ioccontainer) disallow non-object values?

[](#why-does-ioccontainer-disallow-non-object-values)

[*IocContainer*](#ioccontainer) is explicitly a *service* container, not a general config container for [scalar](https://www.php.net/manual/en/language.types.type-system.php#language.types.type-system.atomic.scalar) or [array](https://www.php.net/manual/en/language.types.array.php) values. (Ioc-Interop questions what it means, or if it is possible, to get a "shared" scalar or array that works the same as a "shared" object.) Limiting services to objects helps maintain consistent expectations regarding service types and behavior.

Ioc-Interop recognizes that implementors and consumers often want to make config values easily available. Instead of storing config values directly inside a container, Ioc-Interop encourages the use of one or more config services or value objects to make those values available.

### Why does [*IocContainer*](#ioccontainer) define `getService()` and not just `get()` ?

[](#why-does-ioccontainer-define-getservice-and-not-just-get-)

The vast majority of researched projects, whether PSR-11 conforming or not, use the method name `get()`. Contra the research, Ioc-Interop asserts that `get()`is too generic, and that the method name should hint at what is being gotten; thus, `getService()`.

---

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance80

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity20

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90.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 ~0 days

Total

2

Last Release

104d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25754?v=4)[Paul M. Jones](/maintainers/pmjones)[@pmjones](https://github.com/pmjones)

---

Top Contributors

[![pmjones](https://avatars.githubusercontent.com/u/25754?v=4)](https://github.com/pmjones "pmjones (29 commits)")[![niden](https://avatars.githubusercontent.com/u/1073784?v=4)](https://github.com/niden "niden (3 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ioc-interop-interface/health.svg)

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

PHPackages © 2026

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