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

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

fas/autowire
============

Fast and simple autowiring

0.2.2(4y ago)01732MITPHPPHP &gt;=7.4.0

Since Jun 30Pushed 4y ago1 watchersCompare

[ Source](https://github.com/gielfeldt/fas-autowire)[ Packagist](https://packagist.org/packages/fas/autowire)[ Docs](https://github.com/gielfeldt/fas-autowire)[ RSS](/packages/fas-autowire/feed)WikiDiscussions main Synced 5d ago

READMEChangelogDependencies (8)Versions (8)Used By (2)

[![Build Status](https://github.com/gielfeldt/fas-autowire/actions/workflows/test.yml/badge.svg)](https://github.com/gielfeldt/fas-autowire/actions/workflows/test.yml)[![Test Coverage](https://camo.githubusercontent.com/8b7b45d4683d29ecf15ae32fe413e9dd7849c2c3f52e43f762d484852325155e/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6769656c66656c64742f34343062316338626562313432386237313765643233656536373331303330342f7261772f6661732d6175746f776972655f5f6d61696e2e6a736f6e)](https://camo.githubusercontent.com/8b7b45d4683d29ecf15ae32fe413e9dd7849c2c3f52e43f762d484852325155e/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6769656c66656c64742f34343062316338626562313432386237313765643233656536373331303330342f7261772f6661732d6175746f776972655f5f6d61696e2e6a736f6e)

[![Latest Stable Version](https://camo.githubusercontent.com/f216c121c7dd3e37667433dbf6fbb7ef0565f51520890a0ec8fb6ea1b0c9df6f/68747470733a2f2f706f7365722e707567782e6f72672f6661732f6175746f776972652f762f737461626c652e737667)](https://packagist.org/packages/fas/autowire)[![Latest Unstable Version](https://camo.githubusercontent.com/1af638fada8b7f9ba89034941f422b14a2e6bcaef5db904685734f58b7959c66/68747470733a2f2f706f7365722e707567782e6f72672f6661732f6175746f776972652f762f756e737461626c652e737667)](https://packagist.org/packages/fas/autowire#dev-main)[![License](https://camo.githubusercontent.com/95bd6d3ab78d4de0dfc96190f8d547d4d57d3aeb57828ed826a298fb57f197a9/68747470733a2f2f706f7365722e707567782e6f72672f6661732f6175746f776972652f6c6963656e73652e737667)](https://github.com/gielfeldt/fas-autowire/blob/main/LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/e1fd2cb619946363157fcce16a102406099b891bf5c1ff02e09b97044fcd6f02/68747470733a2f2f706f7365722e707567782e6f72672f6661732f6175746f776972652f646f776e6c6f6164732e737667)](https://camo.githubusercontent.com/e1fd2cb619946363157fcce16a102406099b891bf5c1ff02e09b97044fcd6f02/68747470733a2f2f706f7365722e707567782e6f72672f6661732f6175746f776972652f646f776e6c6f6164732e737667)

Installation
============

[](#installation)

```
composer require fas/autowire
```

Introduction
============

[](#introduction)

This library introduces autowiring capabilities using any PSR-11 container. A very simple container is also provided with this library.

Usage
=====

[](#usage)

Create object
-------------

[](#create-object)

```
require __DIR__ . '/../vendor/autoload.php';

use Fas/Autowire/Autowire;

$autowire = new Autowire();

// Autowire all constructor arguments
$myObject = $autowire->new(MyClass::class);

// Override some constructor arguments
$myObject = $autowire->new(MyClass::class, ['some_argument' => 'test-value']);

// Call a method with no arguments (autowire all arguments)
$autowire->call(function (DateTime $datetime, MyClass $myObject) {
    // do stuff
});

// Override argument
$autowire->call(function (DateTime $datetime, MyClass $myObject) {
    // do stuff
}, ['datetime' => new DateTime('2021-07-01 12:34:56')]);

// Any callable will do
// Plain function
$upperCased  = $autowire->call('strtoupper', ['str' => 'something-in-lower-case']);

// Static method
$datetime = $autowire->call([DateTime::class, 'createFromFormat'], [
    'format' => 'Y-m-d H:i:s',
    'time' => '2021-01-02 12:34:56', // php7
    'datetime' => '2021-01-02 12:34:56', // php8
    'object' => new DateTimeZone('Europe/Copenhagen'),
]);

// Instance method
$autowire->call([new DateTime, 'setTime'], ['hour' => 0, 'minute' => 1, 'second' => 2, 'microseconds' => 123]);

// Invokable class
$autowire->call($myInvokableClass, ['my_param' => 'test']);
```

Using Autowiring for any psr-11 container:

```
$container = new MyPsrContainer();
$autowire = new Autowire($container);
```

Using the fas/autowire container

```
$container = new Container();
$container->set(LoggerInterface::class, NullLogger::class);

$autowire = new Autowire($container);
$autowire->call(function (LoggerInterface $logger) {
    $logger->info("Logging using whatever logger is defined for LoggerInterface in the container");
});
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

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

Total

7

Last Release

1763d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e93f60ea3dd735998209863ed3e064b4aa440db3c23b08f44bf0655c28b0bd3c?d=identicon)[gielfeldt](/maintainers/gielfeldt)

---

Top Contributors

[![gielfeldt](https://avatars.githubusercontent.com/u/4096963?v=4)](https://github.com/gielfeldt "gielfeldt (19 commits)")

---

Tags

containerdiautowire

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[league/container

A fast and intuitive dependency injection container.

86387.8M343](/packages/league-container)[php-di/php-di

The dependency injection container for humans

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

A serializable dependency injection container with constructor and setter injection, interface and trait awareness, configuration inheritance, and much more.

356968.3k58](/packages/aura-di)[league/tactician-container

Tactician integration for any container implementing PSR-11

7710.1M23](/packages/league-tactician-container)[mrclay/props-dic

Props is a simple DI container that allows retrieving values via custom property and method names

3611.7M3](/packages/mrclay-props-dic)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)

PHPackages © 2026

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