PHPackages                             webapper/d3i - 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. [Framework](/categories/framework)
4. /
5. webapper/d3i

ActiveLibrary[Framework](/categories/framework)

webapper/d3i
============

D3I (Dynamic Decorator Dependency Injection) is a replacement of Pimple

013PHP

Since Dec 20Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Webapper/d3i)[ Packagist](https://packagist.org/packages/webapper/d3i)[ RSS](/packages/webapper-d3i/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

D3I
===

[](#d3i)

D3I (Dynamic Decorator Dependency Injection) is a replacement of Pimple which I suggest to use for Silex-alike frameworks.

Main Definitions
================

[](#main-definitions)

Container
---------

[](#container)

The Container objects are for keeping services and other values (eg. configuration setting values). You can access for all values by using property access (arrow-style: `->key`) and array item access (brackets-style: `[key]`).

When you accessing an item as a property and its a Provider, the provider will be called and you will give its service:

```
$container = new Container();
$container->my_service = Provider::Create(function(Container $c) {...return $service;})->share(); // registering a service
$service = $container->my_service; // getting the unique instance of the "my_service" service
```

Provider
--------

[](#provider)

This is for encapsulating a service to be registered. You can get, share, protect, or extend a service by using this class.

Getting a service:

```
$service = $provider($container);
```

Sharing a service:

```
$provider->share();
```

Protecting a service will always returning a new instance of a service when getting from container:

```
$provider->protect();
```

Extending a service:

```
$extendedProvider = $provider->extend(function(Container $c, $s) {
	// ...using of parent container
	$foo = $c['foo'] + 1;
	// ...using of parent service
	$s->setFoo($foo);
	return $s;
});
```

...or using a provider extension:

```
$container->my_extension = Provider::Create(function(Container $c, $s=null) {
	// checking whether if extending a service or not:
	if ($s === null) return new Service(); // returning a simple service rather than extending it

	// ...using of parent container
	$foo = $c['foo'] + 1;
	// ...using of parent service
	$s->setFoo($foo);
	return $s; // returns the extended service
})->share();
...
$extendedProvider = $container['my_service']->extend($container['my_extension']);
```

This last way of extending is useful when you want to use an extension as a standalone service too.

Query Parser
------------

[](#query-parser)

D3I uses a special accessing style, let we call as *D3I queries*. You can use it by both property and array access but we suggest to use it only by array access.

By D3I queries you can access to sub-items by using a single-line query as a container key, without the need of accessing it by level to level. Useful when you want to refer to services or settings in a setting and want to access to the referred item quickly.

For example, let we have a configuration setting, creating a service based on the setting, and accessing a setting by using a D3I query:

```
$container = Container::Create([
	'my_service'	=> [
		'settings'	=> [
			'welcome_str' => 'Hello %s!'
		]
	]
]);

class MyService {
	public $settings;
	function __construct($settings) {
		$this->settings = $settings;
	}
	function getWelcome($to = 'World') {
		// getting the welcome_str property by querying service
		return sprintf($container['@my_service.settings.welcome_str'], $to);
	}
}

$container->my_service = Provider::Create(function(Container $c) {
	// getting original settings by accessing the mutated original value of this provider
	return new MyService($c['!my_service.settings']);
})
	->mutate($container['my_service']) // mutate the original value before of overlapping it
	->share();

echo $container->my_service->getWelcome();
// -> "Hello World!"
```

You can also use "#" (hash mark) for annotate an integer key of an array.

Contribution and Legal info
---------------------------

[](#contribution-and-legal-info)

Please, feel free to contribute!

Choosed licence for this project is [![WTFPL](https://camo.githubusercontent.com/4051644883ab2869f11be71537ea53f57bbb44f1dfa2da471ab524f02f87b331/687474703a2f2f7777772e777466706c2e6e65742f77702d636f6e74656e742f75706c6f6164732f323031322f31322f777466706c2d62616467652d342e706e67)](http://www.wtfpl.net/), therefore see it to know the conditions. Thank you!

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![assarte](https://avatars.githubusercontent.com/u/5679362?v=4)](https://github.com/assarte "assarte (14 commits)")

### Embed Badge

![Health badge](/badges/webapper-d3i/health.svg)

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

###  Alternatives

[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M290](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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