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.

v1.0.0(1mo ago)04.9k↓73.3%1GPL-3.0-or-laterPHP

Since Jan 17Pushed 1mo ago1 watchersCompare

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

READMEChangelogDependencies (4)Versions (3)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

47

—

FairBetter than 93% of packages

Maintenance94

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

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

Every ~1961 days

Total

2

Last Release

32d ago

Major Versions

v0.8 → v1.0.02026-06-02

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/46478?v=4)[Cogent](/maintainers/cogent)[@cogent](https://github.com/cogent)

---

Top Contributors

[![cogentParadigm](https://avatars.githubusercontent.com/u/78707?v=4)](https://github.com/cogentParadigm "cogentParadigm (3 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

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[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.7k16.4k79](/packages/elgg-elgg)[drupal-code-builder/drupal-code-builder

Code generator for Drupal

27253.3k1](/packages/drupal-code-builder-drupal-code-builder)[duxweb/dux-lite

The lightweight framework based on slim php

161.0k9](/packages/duxweb-dux-lite)

PHPackages © 2026

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