PHPackages                             starbug/di - 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. starbug/di

ActiveLibrary[Framework](/categories/framework)

starbug/di
==========

A dependency injection container initialization library.

v0.8(5y ago)04.8k↓50%1GPL-3.0-or-laterPHP

Since Jan 17Pushed 5y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (1)

Starbug Dependency Injection
============================

[](#starbug-dependency-injection)

A dependecy injection meta package and container initialization library for [PHP-DI](https://github.com/PHP-DI/PHP-DI).

What's included
===============

[](#whats-included)

- [PHP-DI/PHP-DI](https://github.com/PHP-DI/PHP-DI) The actual dependency injection library.
- ContainerFactory - A configurable factory for initializing containers and running post initialization steps.
- DefaultConfigurationHandler - A default handler for the factory that loads container definitions from `etc/di.php` in the root package and overrides from `etc/di.php` in modules that provide it. It can also set the default timezone and register an error handler after the container is initialized.

Usage
=====

[](#usage)

Application bootstrapping
-------------------------

[](#application-bootstrapping)

The simplest way to use this library is to bootstrap your application with it and let it use the default configuration handler.

```
include("vendor/starbug/di/bootstrap/init.php");

// You now have a Psr\Container\ContainerInterface instance
$application = $container->make("MyApp");
```

Direct initialization
---------------------

[](#direct-initialization)

To do the same thing directly.

```
use Starbug\DI\ContainerFactory;

include("vendor/autoload.php");

$container = ContainerFactory::withDefaultHandler()
  ->create();

// You now have a Psr\Container\ContainerInterface instance
$application = $container->make("MyApp");
```

Definitions
-----------

[](#definitions)

The default handler will look for a file at `etc/di.php` to load definitions from. To customize `MyApp` our file might look like this.

```
return [
  "MyApp" => function () {
    $app = new MyApp();
    $app->addMiddleware(new MyMiddleware());
    return $app;
  }
];

```

See the [PHP-DI documentation on PHP definitions](https://php-di.org/doc/php-definitions.html).

Modules
-------

[](#modules)

If you are using [starbug/composer-modules-plugin](https://github.com/cogentParadigm/composer-modules-plugin), the default handler will also check each module for an `etc/di.php` file to load additional definitions from.

Custom Handlers
---------------

[](#custom-handlers)

To use custom handlers, call `withHandlers` instead of `withDefaultHandler` and pass your handlers.

```
use Starbug\DI\ContainerFactory;

$container = ContainerFactory::withHandlers(
  new MyHandler(),
  new SecondHandler()
)->create();
```

Alternatively, if you don't want to use the static helper method you can easily do it manually.

```
use Starbug\DI\ContainerFactory;

$factory = new ContainerFactory();
$factory->addHandler(new MyHandler());
$container = $factory->create();
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

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

1948d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/starbug-di/health.svg)

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

###  Alternatives

[slim/slim-skeleton

A Slim Framework skeleton application for rapid development

1.6k458.7k6](/packages/slim-slim-skeleton)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k5](/packages/elgg-elgg)[php-di/slim-bridge

PHP-DI integration in Slim

1786.7M98](/packages/php-di-slim-bridge)[php-di/silex-bridge

PHP-DI integration in Silex

2465.4k1](/packages/php-di-silex-bridge)[forme/framework

An MVC framework for WordPress.

175.0k3](/packages/forme-framework)

PHPackages © 2026

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