1
0
Fork
You've already forked wire
0
Autowiring object creator and argument resolver
  • PHP 100%
Thomas Ernst 8fcd0a237e
All checks were successful
ci / ci (push) Successful in 1m25s
Update README badges
2026年06月10日 21:22:55 +02:00
.forgejo/workflows Allow manual CI runs 2026年06月10日 20:58:19 +02:00
.github Add GitHub mirror README 2026年06月10日 21:14:39 +02:00
docs Update docs tooling 2026年05月12日 15:00:38 +02:00
src The big rename 2026年05月11日 14:07:23 +02:00
tests The big rename 2026年05月11日 14:07:23 +02:00
.editorconfig Sync shared config files 2026年01月30日 22:04:24 +01:00
.gitattributes Update .gitattributes 2026年04月15日 21:00:57 +02:00
.gitignore Update coverage output path 2026年04月13日 16:32:42 +02:00
CHANGELOG.md Update changelog 2026年06月09日 20:24:37 +02:00
composer.json Require dev package v4.2 2026年05月13日 13:12:06 +02:00
LICENSE.md Update license 2026年05月12日 14:25:48 +02:00
mago.toml Update mago.toml 2026年04月13日 12:28:36 +02:00
phpunit.xml.dist Update coverage settings 2026年05月12日 19:26:51 +02:00
psalm.xml.dist Rename config files from *.dist.xml to *.xml.dist 2026年04月15日 17:48:42 +02:00
README.md Update README badges 2026年06月10日 21:22:55 +02:00

Celemas Wire

ci code coverage type coverage psalm level Software License

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: celemas.dev/wire

Installation

composer require celemas/wire

Basic usage

use Celemas\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');

Scoped container usage

When you pass a scoped container to Creator, callable resolvers and Inject entry lookups resolve against that current scope first.

This allows parent-owned definitions (for example root shared services) and scope-local overrides (for example request-local values) to work together safely.

License

This project is licensed under the MIT license.