PHPackages                             blackcube/injector - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. blackcube/injector

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

blackcube/injector
==================

Static PSR-11 container accessor — get DI everywhere

1.0.0(1mo ago)09↓100%2BSD-3-ClausePHPPHP ^8.0

Since Mar 21Pushed 1mo agoCompare

[ Source](https://github.com/blackcubeio/injector)[ Packagist](https://packagist.org/packages/blackcube/injector)[ Docs](https://github.com/blackcubeio/injector)[ RSS](/packages/blackcube-injector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (2)

Blackcube Injector
==================

[](#blackcube-injector)

> **⚠️ Blackcube Warning**
>
> DI works great — inside methods. Outside, you're on your own.
>
> Static factories, prototype patterns, helper classes — no constructor, no injection point. Injector is a portable container that bridges the gap without depending on the inheritance chain. One `init()` at bootstrap, `get()` wherever the container can't reach.

Static PSR-11 bridge for dependency injection outside of method scope.

[![License](https://camo.githubusercontent.com/6cb285b57819f8de0acfb34923298f4f569f962544e8fe35331da2d163f4e485/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253442d2d332d2d436c617573652d626c75652e737667)](LICENSE.md)[![Packagist Version](https://camo.githubusercontent.com/cd4d2c3d3bccd3707b00783bbe55e07308dc5abf9de5eac45ac713fcf9873228/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626c61636b637562652f696e6a6563746f722e737667)](https://packagist.org/packages/blackcube/injector)[![Warning](https://camo.githubusercontent.com/f6bc4777f4b5c33df3e4f07b00623d3231016d0291e5ce1bf40b0dc084c71145/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f426c61636b637562652d5761726e696e672d6f72616e6765)](BLACKCUBE_WARNING.md)

Installation
------------

[](#installation)

```
composer require blackcube/injector
```

Why Injector?
-------------

[](#why-injector)

SituationProblemStatic factory (`File::from()`)No constructor, no DIPrototype pattern (`CacheFile`)Clone-based, container unreachableHelper classesNeed a service, have no injection point**Injector**`Injector::get(MyService::class)` — done**One class. Three methods. Zero magic.**

Quick Start
-----------

[](#quick-start)

### 1. Bootstrap (once)

[](#1-bootstrap-once)

```
use Blackcube\Injector\Injector;

// In your bootstrap or container setup
Injector::init($container);
```

With Yii config-plugin, this happens automatically via `config/common/bootstrap.php`.

### 2. Use anywhere

[](#2-use-anywhere)

```
use Blackcube\Injector\Injector;

// Get a service
$logger = Injector::get(LoggerInterface::class);

// Check availability
if (Injector::has(CacheInterface::class)) {
    $cache = Injector::get(CacheInterface::class);
}
```

API
---

[](#api)

MethodDescription`Injector::init(ContainerInterface $container)`Store the container (call once at bootstrap)`Injector::get(string $id): mixed`Retrieve a service — throws `RuntimeException` if not initialized`Injector::has(string $id): bool`Check if a service exists — returns `false` if not initializedYii Integration
---------------

[](#yii-integration)

The package ships with config-plugin support. Add `blackcube/injector` to your project and the bootstrap runs automatically:

```
// config/common/bootstrap.php (shipped with package)
static function (ContainerInterface $container): void {
    Injector::init($container);
};
```

No manual setup required.

Tests
-----

[](#tests)

```
vendor/bin/codecept run Unit
```

License
-------

[](#license)

BSD-3-Clause. See [LICENSE.md](LICENSE.md).

Author
------

[](#author)

Philippe Gaultier

###  Health Score

40

—

FairBetter than 87% of packages

Maintenance97

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

48d ago

### Community

Maintainers

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

---

Top Contributors

[![pgaultier](https://avatars.githubusercontent.com/u/545714?v=4)](https://github.com/pgaultier "pgaultier (2 commits)")

---

Tags

containerPSR-11diinjector

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/blackcube-injector/health.svg)

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

2.8k48.9M987](/packages/php-di-php-di)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)[devanych/di-container

Simple implementation of a PSR-11 dependency injection container

124.2k3](/packages/devanych-di-container)

PHPackages © 2026

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