PHPackages                             sysvyz/brunt - 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. sysvyz/brunt

ActiveLibrary[Framework](/categories/framework)

sysvyz/brunt
============

PHP7 Dependency Injection Framework

1.0.2(9y ago)137MITPHPPHP &gt;=7.0.0

Since Apr 26Pushed 9y ago1 watchersCompare

[ Source](https://github.com/sysvyz/brunt)[ Packagist](https://packagist.org/packages/sysvyz/brunt)[ Docs](https://github.com/sysvyz/brunt)[ RSS](/packages/sysvyz-brunt/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (6)Dependencies (3)Versions (13)Used By (0)

Brunt
=====

[](#brunt)

Brunt is a simple but powerful dependency injection framework. Since php7, reflection can be used to analyze constructors properly.

Usage
-----

[](#usage)

### Composer

[](#composer)

```
  "require": {
    "sysvyz/brunt": "1.0.*",
  },
```

### Test

[](#test)

Unit tests in `/test/`

`phpunit``php vendor/bin/phpunit`

### Include

[](#include)

simply use `composer dump-autoload`

then `include __DIR__ . '/vendor/autoload.php';`

### Examples

[](#examples)

#### Example 1: basic usage

[](#example-1-basic-usage)

```
$injector = new Brunt\Injector(null);

/** @var Engine $engine */
$engine = $injector->get(Engine::class);
```

#### Example 2: magic get

[](#example-2-magic-get)

```
$engine = $injector->get(Engine::class);
//is equivalent to
$engine = $injector->{Engine::class};
```

#### Example 3: define providers

[](#example-3-define-providers)

```
$injector = new Injector(null);

//                          TOKEN           PROVIDER            CLASS
$injector->addProviders([Engine::class => ClassProvider::init(HeavyEngine::class)]);

/** @var Engine $engine */
$engine = $injector->get(Engine::class);
```

#### Example 4: Binding

[](#example-4-binding)

Bindings are a more convenient way to define Providers

```
$injector->bind([

    bind('%SomeValue%')
    ->toValue(3.1415),

    bind(Car::class)
    ->toClass(Car::class),

    bind(Request::class)
        ->toFactory(function (Injector $injector) {
            return Request::createFromGlobals();
        })
])
```

#### Example 5: Singleton

[](#example-5-singleton)

Just call `singleton()` and the provider always returns the same object.

```
$injector = new Injector(null);

//                          TOKEN           PROVIDER            CLASS              SINGLETON
$injector->addProviders([Engine::class => ClassProvider::init(HeavyEngine::class)->singleton()]);

/** @var Engine $engine */
$engine = $injector->get(Engine::class);
```

or as binding

```
$injector = new Injector(null);
$injector->bind([

    bind(Car::class)
    ->toClass(Car::class)->singleton(),

]);
$car = $injector->get(Car::class)
```

#### Example 6: Lazy

[](#example-6-lazy)

Just call `lazy()` and the provider returns a proxy object the real object will be created on first use.

```
$injector = new Injector(null);

//                          TOKEN           PROVIDER            CLASS              LAZY
$injector->addProviders([Engine::class => ClassProvider::init(HeavyEngine::class)->lazy()]);

/** @var Engine $engine */
$engine = $injector->get(Engine::class); //returns a proxy object
```

or as binding

```
$injector = new Injector(null);
$injector->bind([

    bind(Car::class)
    ->toClass(Car::class)->lazy(),

]);
$car = $injector->get(Car::class) //returns a proxy object

$car->honk() //creates the actual car and honks
```

the proxy object inherits from the actual class, so it can be used as if it was the object it passes instanceof and function parameter type declarations

#### Example 7: Lazy and Singleton

[](#example-7-lazy-and-singleton)

combine lazy and singleton (order doesn't matter)

```
bind(Car::class)->lazy()->singleton()
```

```
ClassProvider::init(Car::class)->lazy()->singleton();
```

#### Example 7: Alias

[](#example-7-alias)

... alias

```
$injector->addProviders([
    HeavyEngine::class => ClassProvider::init(HeavyEngine::class)->lazy()
    Engine::class => AliasProvider::init(HeavyEngine::class)
]);
$heavyEngine = $injector->get(Engine::class); //returns a proxy object for HeavyEngine
```

#### Example 7: Hierarchy

[](#example-7-hierarchy)

coming up...

#### Example Repo:

[](#example-repo)

[working example using brunt](https://github.com/sysvyz/brunt-example)

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 96.9% 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 ~36 days

Recently: every ~76 days

Total

10

Last Release

3433d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/26d47903d0b8f9c20ad74bfcf3b521f6aba8f94b3b25577d5015a7b82b722974?d=identicon)[mo-ba](/maintainers/mo-ba)

---

Top Contributors

[![mo-ba](https://avatars.githubusercontent.com/u/13025011?v=4)](https://github.com/mo-ba "mo-ba (63 commits)")[![angus9000](https://avatars.githubusercontent.com/u/20687942?v=4)](https://github.com/angus9000 "angus9000 (2 commits)")

---

Tags

dependency-injectiondi

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sysvyz-brunt/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.9k556.2M21.3k](/packages/laravel-framework)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.9M534](/packages/pimcore-pimcore)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k257.3M12.3k](/packages/symfony-framework-bundle)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k555.0M2.8k](/packages/aws-aws-sdk-php)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k99.8M350](/packages/laravel-horizon)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k20](/packages/tempest-framework)

PHPackages © 2026

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