PHPackages                             fuelphp/dependency-injection - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. fuelphp/dependency-injection

AbandonedLibrary[Utility &amp; Helpers](/categories/utility)

fuelphp/dependency-injection
============================

Fuel Dependency package based on League\\Container

112212[1 issues](https://github.com/fuelphp/dependency/issues)PHP

Since May 9Pushed 10y ago6 watchersCompare

[ Source](https://github.com/fuelphp/dependency)[ Packagist](https://packagist.org/packages/fuelphp/dependency-injection)[ RSS](/packages/fuelphp-dependency-injection/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Fuel Dependency
===============

[](#fuel-dependency)

[![Build Status](https://camo.githubusercontent.com/9cc28584f3ed37c2784f6b3143a2e2841d7cc154710e353342b95706b07f0aa6/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6675656c7068702f646570656e64656e63792e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/fuelphp/dependency)[![Code Coverage](https://camo.githubusercontent.com/4b7dcaa5db64ad7afed2d311bb7788d068f22e40ae2347d1647bc8a15c20440c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6675656c7068702f646570656e64656e63792e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/fuelphp/dependency)[![Quality Score](https://camo.githubusercontent.com/1b42a9bcc546b46a537b265c3a26b76936a8d3d1e53b8f7a314fc2e7254bdc4f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6675656c7068702f646570656e64656e63792e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/fuelphp/dependency)

**Fuel Dependency package based on [League\\Container](http://container.thephpleague.com).**

Usage
-----

[](#usage)

The Dependency package is an extension of [League\\Container](http://container.thephpleague.com) responsible for handling dependencies in FuelPHP framework. Most of the functionalities are the same, but there are some custom ones as well. It means that we don't encourage anyone to use this package on it's own since the additions are mostly FuelPHP specific.

This documentation covers the basic usage of the Container, also the added features. For full documentation check the original [documentation](http://container.thephpleague.com).

### Container

[](#container)

The container is the primary component of the dependency package and ties all the parts together. You can look at this as the (PHP) object store. The container is where you register resources, service providers and retrieve dependencies.

```
$container = new Fuel\Dependency\Container;
```

### Definitions

[](#definitions)

A definition is either a class string name or a closure which returns an instance or a class name.

#### String definition

[](#string-definition)

```
// Register
$container->add('string', 'stdClass');

// Resolve
$instance = $container->get('string');
```

#### Closure definition

[](#closure-definition)

```
// Register
$container->add('closure.object', function() {
	return new stdClass;
});

// Resolve
$instance = $container->get('closure.object');
```

### Service Providers

[](#service-providers)

Service providers are used to expose packages to the Container. A Service Provider can provide the container with resources but also act on a namespace. A namespace is a string prefix which maps identifiers to the providers factory method.

```
use League\Container\ServiceProvider;

class MyProvider extends ServiceProvider
{
	protected $provides = ['some.identifier', 'other.resource'];

	public function register()
	{
		$this->container->add('some.identifier', 'stdClass');
		$this->container->singleton('other.resource', function() {
			return new Something($this->container->resolve('database.connection'));
		));
	}
}
```

### Fuel extensions

[](#fuel-extensions)

Fuel adds two main functionalities to the Container:

- Creating multiton instances
- Creating new instances regardless it is singleton or not

#### Multiton

[](#multiton)

```
// Register
$container->add('closure::object1', function() {
	return new stdClass;
});
$container->add('closure::object2', function() {
	return new stdClass;
});

// Resolve
object1 = $container->multiton('closure', 'object1');
objects = $container->multiton('closure');
```

#### Forge

[](#forge)

```
// Register
$container->singleton('closure.object', function() {
	return new stdClass;
});

// Resolve
// Always returns a newly resolved definition
$instance = $container->forge('closure.object');
```

Contributing
------------

[](#contributing)

Thank you for considering contribution to FuelPHP framework. Please see [CONTRIBUTING](https://github.com/fuelphp/fuelphp/blob/master/CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 53.7% 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/fb5aa7fe428e4862b98fa6b53f716360d5eff8ff5e25f346d0c34bdcf3bbba62?d=identicon)[WanWizard](/maintainers/WanWizard)

---

Top Contributors

[![sagikazarmark](https://avatars.githubusercontent.com/u/1226384?v=4)](https://github.com/sagikazarmark "sagikazarmark (44 commits)")[![WanWizard](https://avatars.githubusercontent.com/u/456954?v=4)](https://github.com/WanWizard "WanWizard (23 commits)")[![frankdejonge](https://avatars.githubusercontent.com/u/534693?v=4)](https://github.com/frankdejonge "frankdejonge (14 commits)")[![thefuzzy0ne](https://avatars.githubusercontent.com/u/3922428?v=4)](https://github.com/thefuzzy0ne "thefuzzy0ne (1 commits)")

### Embed Badge

![Health badge](/badges/fuelphp-dependency-injection/health.svg)

```
[![Health](https://phpackages.com/badges/fuelphp-dependency-injection/health.svg)](https://phpackages.com/packages/fuelphp-dependency-injection)
```

###  Alternatives

[jakewhiteley/php-sets

An implementation of a Java-like Set data structure for PHP. A Set is an iterable data structure which allows strict-type storage of unique values.

1827.5k](/packages/jakewhiteley-php-sets)[marciocamello/yii2-x-editable

X-editable extensions for Yii 2, based in X-editable with Bootstrap

228.8k2](/packages/marciocamello-yii2-x-editable)

PHPackages © 2026

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