- PHP 100%
|
Thomas Ernst
8fcd0a237e
All checks were successful
ci / ci (push) Successful in 1m25s
|
||
|---|---|---|
| .forgejo/workflows | Allow manual CI runs | |
| .github | Add GitHub mirror README | |
| docs | Update docs tooling | |
| src | The big rename | |
| tests | The big rename | |
| .editorconfig | Sync shared config files | |
| .gitattributes | Update .gitattributes | |
| .gitignore | Update coverage output path | |
| CHANGELOG.md | Update changelog | |
| composer.json | Require dev package v4.2 | |
| LICENSE.md | Update license | |
| mago.toml | Update mago.toml | |
| phpunit.xml.dist | Update coverage settings | |
| psalm.xml.dist | Rename config files from *.dist.xml to *.xml.dist | |
| README.md | Update README badges | |
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.