PHPackages                             tobento/service-autowire - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. tobento/service-autowire

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

tobento/service-autowire
========================

Autowiring for PSR-11 containers.

2.0.1(7mo ago)249920MITPHPPHP &gt;=8.4

Since Jul 17Pushed 7mo ago2 watchersCompare

[ Source](https://github.com/tobento-ch/service-autowire)[ Packagist](https://packagist.org/packages/tobento/service-autowire)[ Docs](https://www.tobento.ch)[ RSS](/packages/tobento-service-autowire/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (14)Used By (20)

Autowire Service
================

[](#autowire-service)

The Autowire Service provides autowiring for PSR-11 containers.

Table of Contents
-----------------

[](#table-of-contents)

- [Getting started](#getting-started)
    - [Requirements](#requirements)
    - [Highlights](#highlights)
    - [Simple Example](#simple-example)
- [Documentation](#documentation)
    - [Resolve](#resolve)
    - [Call](#call)
- [Credits](#credits)

---

Getting started
===============

[](#getting-started)

Add the latest version of the autowire service running this command.

```
composer require tobento/service-autowire

```

Requirements
------------

[](#requirements)

- PHP 8.4 or greater

Highlights
----------

[](#highlights)

- Framework-agnostic, will work with any project

Simple Example
--------------

[](#simple-example)

Here is a simple example of how to use the Autowire service.

```
use Tobento\Service\Autowire\Autowire;

// Autowiring an object
$foo = new Autowire($container)->resolve(Foo::class);

// Call method using autowiring
$value = new Autowire($container)->call([Foo::class, 'method']);
```

Documentation
=============

[](#documentation)

Resolve
-------

[](#resolve)

Define any build-in parameters which are not resolvable, either by parameter name or position.

```
use Tobento\Service\Autowire\Autowire;

// By name
$foo = new Autowire($container)->resolve(Foo::class, ['name' => 'value']);

// By position
$foo = new Autowire($container)->resolve(Foo::class, [2 => 'value']);
```

You might use a try/catch block:

```
use Tobento\Service\Autowire\Autowire;
use Tobento\Service\Autowire\AutowireException;

try {
    $foo = new Autowire($container)->resolve([Foo::class, 'method']);
} catch (AutowireException $e) {
    // not resolvable
}
```

Call
----

[](#call)

Define any build-in parameters which are not resolvable, either by parameter name or position.

```
use Tobento\Service\Autowire\Autowire;

// Using array callable
$value = new Autowire($container)->call([Foo::class, 'method'], ['name' => 'value']);

// Using closure
$value = new Autowire($container)->call(function(Foo $foo, $name) {
    return $name;
}, ['name' => 'value']);

var_dump($value); // string(5) "value"

// Using class with __invoke
$value = new Autowire($container)->call(Invokable::class, ['name' => 'value']);

// Using Class::method syntax
$value = new Autowire($container)->call('Foo::method', ['name' => 'value']);
```

Credits
=======

[](#credits)

- [Tobias Strub](https://www.tobento.ch)
- [All Contributors](../../contributors)

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance64

Regular maintenance activity

Popularity20

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity76

Established project with proven stability

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

Recently: every ~230 days

Total

14

Last Release

222d ago

Major Versions

1.x-dev → 2.02025-09-23

PHP version history (2 changes)1.0.0PHP &gt;=8.0

2.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/055d6a1b5c2384bb179c75ab0b55914231d898fdc4dffeb30770f81200e52206?d=identicon)[TOBENTOch](/maintainers/TOBENTOch)

---

Top Contributors

[![tobento-ch](https://avatars.githubusercontent.com/u/16684832?v=4)](https://github.com/tobento-ch "tobento-ch (25 commits)")

---

Tags

containerPSR-11Autowiringpackagetobento

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tobento-service-autowire/health.svg)

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

2.8k48.9M994](/packages/php-di-php-di)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)[devanych/di-container

Simple implementation of a PSR-11 dependency injection container

124.2k3](/packages/devanych-di-container)[chubbyphp/chubbyphp-container

A simple PSR-11 container implementation.

1978.4k14](/packages/chubbyphp-chubbyphp-container)[selective/container

A simple PSR-11 container implementation with autowiring.

1220.4k4](/packages/selective-container)

PHPackages © 2026

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