PHPackages                             dispify/weaver - 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. dispify/weaver

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

dispify/weaver
==============

Simple Dependency Injection container with autoconfiguration and autowiring

v1.0.0(5y ago)11MITPHPPHP ^7.1

Since Sep 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Dispify/weaver)[ Packagist](https://packagist.org/packages/dispify/weaver)[ RSS](/packages/dispify-weaver/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/f63d36a5ea438692132499af5041b535920f692d60c946dd1e19cffd196909b8/68747470733a2f2f7472617669732d63692e6f72672f446973706966792f7765617665722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Dispify/weaver)[![codecov](https://camo.githubusercontent.com/47242c368acd67f1578b6f9452c341f447f74af7cea030bc40e4544a8feeeee3/68747470733a2f2f636f6465636f762e696f2f67682f446973706966792f7765617665722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Dispify/weaver)[![GitHub license](https://camo.githubusercontent.com/390426a86d8a61cb11b7db6f409ff8f59148207acffde1af1586089364f6c22a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f446973706966792f776561766572)](https://github.com/Dispify/weaver/blob/master/LICENSE)

[![Packagist PHP Version Support](https://camo.githubusercontent.com/53dab0faf78b071b1e9c1873d58b78da2c09f7a12f8c959dce47bb3b0c589387/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646973706966792f776561766572)](https://camo.githubusercontent.com/53dab0faf78b071b1e9c1873d58b78da2c09f7a12f8c959dce47bb3b0c589387/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646973706966792f776561766572)[![PSR-11 Support](https://camo.githubusercontent.com/6e7307626e19d49dc76f655cf48a0e97ad76c6c7a9cf29cd0e8f3c59ab01f238/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7073722d2d31312d6f6b2d677265656e)](https://camo.githubusercontent.com/6e7307626e19d49dc76f655cf48a0e97ad76c6c7a9cf29cd0e8f3c59ab01f238/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7073722d2d31312d6f6b2d677265656e)

Weaver
======

[](#weaver)

The simple Dependency Injection container with autoconfiguration and autowiring. Inspired by [The DependencyInjection Component](https://symfony.com/doc/current/components/dependency_injection.html).

This library can help you to configure a lot of services for an example for a module test.

Getting started
---------------

[](#getting-started)

Before using Weaver in your project, add it to your composer.json file:

```
$ composer require dispify/weaver
```

Usage
-----

[](#usage)

> ⚠️ When you register any service it is registered with specified class name neither implemented interfaces nor class aliases

> ⚠️ When the service has been instantiated Weaver overwrites all services which names are equals to the implemented interfaces, or the class aliases of the service with this instance of the service.

```
class A {}
class B {
    public function __construct(A $a) {}
}

$weaver = new \Dispify\Weaver\Weaver();
$weaver->weave(B::class, $arguments = []); // register dependency
$weaver->get(B::class); // instantiate and return object of B. The service of A is created via autowiring
```

Features
--------

[](#features)

##### Global shared parameters &amp; Manual instantiated external services

[](#global-shared-parameters--manual-instantiated-external-services)

The pre-defined parameters and the services can be provided manually. Any scalar value will be always registered as a named parameter.
Any object will be registered as a service with its class name, its parents class names, implemented interfaces and its declared class aliases (requires to include package "dispify/class\_aliases")

##### Lazy instantiating

[](#lazy-instantiating)

When you register any service you should provide a class name of the service and an array of the arguments of the constructor. The service will be instantiated only when this service will be requested by another service or an external caller.

The array of the arguments can be both an array of key-value and an indexed array.

##### Autoconfiguration

[](#autoconfiguration)

When service is requested to be instantiated the first action is determination of constructor's arguments via reflection. Weaver tries to resolve each argument with existent data such as arguments, services, shared parameters or default values.

Weaver uses next ways to resolve the determined argument:

- Pick the argument by the name from the array of the arguments if it exists;
- Pick the argument by the index from the array of the arguments if it exists;
- Get the argument as a service if it is an object;
- Pick the argument by the name from the shared parameters array if it exists;
- Use a default value of the argument if it is specified;

The variadic argument is ignored by design. It will be able to change later.

##### Autowiring

[](#autowiring)

When Weaver is resolving the argument which is an object it gets a service with a class name of the argument.

If the service is not registered than Weaver tries to register this service with the class name.

> ⚠️ If the class name does not exist or there is an interface is specified than the exception will be thrown.

Next Weaver is instantiating this service via the workflow of the lazy instantiating.

PSR-11 compatibility
====================

[](#psr-11-compatibility)

Weaver is compatible with PSR-11, so you can pass any string as an identifier of the service when you are getting or checking existence the service. But you cannot register the service with a random string as the identifier. The class name or interface is allowed.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

2080d ago

### Community

Maintainers

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

---

Top Contributors

[![Disparity](https://avatars.githubusercontent.com/u/621344?v=4)](https://github.com/Disparity "Disparity (1 commits)")

---

Tags

containerPSR-11dependency-injection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dispify-weaver/health.svg)

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

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

A flexible dependency injection container

20260.4k6](/packages/slince-di)[phpwatch/simple-container

A fast and minimal PSR-11 compatible Dependency Injection Container with array-syntax and without auto-wiring

1810.1k2](/packages/phpwatch-simple-container)

PHPackages © 2026

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