conia / wire
Autowiring object creator and callable argument resolver
0.3.0
2024-01-18 18:49 UTC
Requires
- psr/container: ^2.0
Requires (Dev)
- conia/development: ^1.0
- dealerdirect/phpcodesniffer-composer-installer: ^1.0
- ernst/coverlyzer: ^0.1.1
- phpunit/phpunit: ^10.4
- vimeo/psalm: ^5.15
README
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.
Documentation can be found on the website: conia.dev/wire
Installation
composer require conia/wire
Basic usage
use Conia\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
Conia Wire is released under the MIT license.
Copyright © 2023-2024 ebene fünf GmbH. All rights reserved.