PHPackages                             bomoko/lethabadi - 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. bomoko/lethabadi

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

bomoko/lethabadi
================

A simple DI container implementation

0.0.0(8y ago)013MITPHPPHP ^7.0

Since Sep 22Pushed 8y agoCompare

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

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

Lethaba DI
==========

[](#lethaba-di)

This is a simple DI container, inspired by (read, shamelessly copied from) [Pimple 1.x](https://github.com/silexphp/Pimple/tree/1.1)

Usage
-----

[](#usage)

Instantiate your container

`$container = new DIContainer();`

you can optionally pass an array of initial parameters at construction time

`$container = new DIContainer(['parameter' => 'value']);`

### Retrieving Parameters and Services

[](#retrieving-parameters-and-services)

There are two options for pulling parameters and services out of the container:

`$output = $container('serviceName');`

and

`$output = $container->get('serviceName'); //PSR-11 style`

### Defining Parameters and Services

[](#defining-parameters-and-services)

You're able to add simple values, objects, and functions by binding them to the container

`$container->bind('serviceName' => $service);`

You can then access the service by invoking the container with the service's name

`$serviceResult = $container('serviceName');`

### Protecting Parameters

[](#protecting-parameters)

If you want to store an invokable object as a parameter, you have to bind it to the container using the protect() method. The container will try to run any invokable by default during service resolution. Protecting the parameter means that you're guaranteed to get back what you put in.

`$container->protect('protectedParameter', function () { return 'will run outside container';});`

### Defining Shared Services

[](#defining-shared-services)

Shared services return the same instance every time the service is resolved. To define a shared service, simply bind it to the container with the bindSingleton method.

```
$container->bindSingleton('serviceName', function ($c) {
   return new someSharedObject($c('someParameter'));
});

```

### Modifying Existing Services

[](#modifying-existing-services)

You're able to modify the behaviour of an existing service by using the extend() method. Service extensions should be invokable with two arguments, first, the value returned by the existing service, and second, the container instance.

Here is an example of defining a service that returns a string, and then extending it to modify the string.

```
$container = new DIContainer();
$container->bind('service', function ($c) {
    return "inside";
});

$container->extend('service', function ($innerResult, $c) {
  return "outside-" . $innerResult . "-outside";
});

$output = $container('service'); //will contain 'outside-inside-outside'

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

3155d ago

### Community

Maintainers

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

---

Top Contributors

[![bomoko](https://avatars.githubusercontent.com/u/297936?v=4)](https://github.com/bomoko "bomoko (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bomoko-lethabadi/health.svg)

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

###  Alternatives

[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k431.1M7.5k](/packages/symfony-dependency-injection)[illuminate/contracts

The Illuminate Contracts package.

704122.9M10.1k](/packages/illuminate-contracts)[illuminate/container

The Illuminate Container package.

31278.1M2.0k](/packages/illuminate-container)[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)

PHPackages © 2026

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