PHPackages                             tomrf/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. tomrf/autowire

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

tomrf/autowire
==============

autowire dependency injection from PSR-11 containers

0.1.2(2y ago)26393MITPHPPHP ^8.0

Since Oct 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tomrf/autowire)[ Packagist](https://packagist.org/packages/tomrf/autowire)[ Docs](http://github.com/tomrf/autowire)[ RSS](/packages/tomrf-autowire/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (7)Versions (11)Used By (3)

autowire - autowire dependency injection from PSR-11 containers
===============================================================

[](#autowire---autowire-dependency-injection-from-psr-11-containers)

[![PHP Version Require](https://camo.githubusercontent.com/45acf0874a7766124804bf58eb4d44d2ed429b43790f1e4a64048b67dde320ff/687474703a2f2f706f7365722e707567782e6f72672f746f6d72662f6175746f776972652f726571756972652f7068703f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tomrf/autowire) [![Latest Stable Version](https://camo.githubusercontent.com/b4630080d03ff07035f62b0da6faf3355c9c3222701082a945fbd6db24946e3e/687474703a2f2f706f7365722e707567782e6f72672f746f6d72662f6175746f776972652f763f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tomrf/autowire) [![License](https://camo.githubusercontent.com/446603e7cf8c697e6edc9394e159719c950f70c541f6931b94a216f1d4bfb74e/687474703a2f2f706f7365722e707567782e6f72672f746f6d72662f6175746f776972652f6c6963656e73653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tomrf/autowire)

A simple PHP library that facilitates autowired dependency injection by fetching class constructor dependencies from one or more PSR-11 containers.

Autowire uses the PHP reflection API to peek at constructor parameter types and injects required and optional dependencies from assigned containers.

📔 [Go to documentation](#documentation)

Installation
------------

[](#installation)

Installation via composer:

```
composer require tomrf/autowire
```

Usage
-----

[](#usage)

```
$autowire = new \Tomrf\Autowire\Autowire();

$instance = $autowire->instantiateClass(MyClassWithDependencies::class, $container);
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

This project is released under the MIT License (MIT). See [LICENSE](LICENSE) for more information.

Documentation
-------------

[](#documentation)

- [Tomrf\\Autowire\\Autowire](#-tomrfautowireautowireclass)
    - [resolveDependencies](#resolvedependencies)
    - [instantiateClass](#instantiateclass)
    - [listDependencies](#listdependencies)

---

### 📂 Tomrf\\Autowire\\Autowire::class

[](#-tomrfautowireautowireclass)

Minimal class that facilitates dependency injection by autowiring class constructor dependencies from one or more PSR-11 containers.

#### resolveDependencies()

[](#resolvedependencies)

Returns array of resolved dependencies for a class constructor.

Dependencies are resolved from one or more PSR-11 containers.

Throws AutowireException if a required dependency could not be met using available containers.

```
public function resolveDependencies(
    object|string $classOrObject,
    Psr\Container\ContainerInterface $containers
): array

@throws   \Tomrf\Autowire\AutowireException
@return   (null|object)[]
```

#### instantiateClass()

[](#instantiateclass)

Return a new instance of a class after successfully resolving all required dependencies using provided containers.

Throws AutowireException if the class does not exist or if a required dependency could not be met using available containers.

```
public function instantiateClass(
    string $class,
    Psr\Container\ContainerInterface $containers
): object

@throws   \Tomrf\Autowire\AutowireException
```

#### listDependencies()

[](#listdependencies)

Returns an array of all dependencies (method parameters) and relevant attributes for a given class or object/callable.

```
public function listDependencies(
    object|string $classOrObject,
    string $methodName = '__construct'
): array

@throws   \Tomrf\Autowire\AutowireException
@return   array[] Array of parameters with attributes
```

---

*Generated 2022-06-28T01:41:09+02:00 using 📚[tomrf/readme-gen](https://packagist.org/packages/tomrf/readme-gen)*

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity51

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

Recently: every ~104 days

Total

10

Last Release

1019d ago

PHP version history (3 changes)0.0.1PHP &gt;=8

0.0.5PHP &gt;=8.0

0.0.6PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2113e52873316a5ad6f705f08f4218b2ee8c4348b0c693bb87bd9359908d23f?d=identicon)[tom@upnode.no](/maintainers/tom@upnode.no)

---

Top Contributors

[![tomrf](https://avatars.githubusercontent.com/u/1669009?v=4)](https://github.com/tomrf "tomrf (45 commits)")

---

Tags

autowirecontainerdependency-injectiondiphppsr-11reflectioncontainerPSR-11dependency-injectionreflectionautowire

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/tomrf-autowire/health.svg)](https://phpackages.com/packages/tomrf-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)[phpwatch/simple-container

A fast and minimal PSR-11 compatible Dependency Injection Container with array-syntax and without auto-wiring

1810.1k2](/packages/phpwatch-simple-container)[devanych/di-container

Simple implementation of a PSR-11 dependency injection container

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

PHPackages © 2026

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