duon/wire

Autowiring object creator and argument resolver

Installs: 78

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/duon/wire

0.4.0 2026-01-30 22:57 UTC

This package is auto-updated.

Last update: 2026-01-31 19:08:24 UTC


README

Software License Codacy Badge Codacy Badge Psalm level Psalm coverage

Wire provides an autowiring object creator that utilizes PHP's reflection capabilities to automatically resolve constructor arguments recursively. It additionally comes with classes that assist in resolving arguments of callables such as functions, methods, closures or class constructors. It can be combined with a PSR-11 dependency injection container.

Wire is a PHP dependency injection tool that automatically constructs objects by resolving their dependencies. Using PHP's reflection API, Wire recursively analyzes and fulfills constructor arguments without manual configuration. It additionally includes utilities for resolving dependencies in various callable types—including functions, methods, closures, and class constructors. Wire seamlessly integrates with PSR-11 compliant dependency injection containers.

Documentation can be found on the website: duon.sh/wire

Installation

composer require duon/wire

Basic usage

use Duon\Wire\Wire;

class Value
{
    public function get(): string
    {
        return 'Autowired Value';
    }
}

class Model
{
    public function __construct(protected Value $value) {}

    public function value(): string
    {
        return $this->value->get();
    }
}

$creator = Wire::creator();
$model = $creator->create(Model::class);

assert($model instanceof Model);
assert($model->value() === 'Autowired Value');

License

This project is licensed under the MIT license.