PHPackages                             tmont/blueshift - 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. tmont/blueshift

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

tmont/blueshift
===============

Simple inversion of control container

1.1.0(12y ago)014WTFPLPHP

Since Jan 22Pushed 12y ago1 watchersCompare

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

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

Blue Shift
==========

[](#blue-shift)

[![Build Status](https://camo.githubusercontent.com/0049f35a739e8c60fc62e0c1c4cff678e056826524d161814387565df0907626/68747470733a2f2f7472617669732d63692e6f72672f746d6f6e742f626c756573686966742e706e67)](https://travis-ci.org/tmont/blueshift)

A simple inversion-of-control container.

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

[](#installation)

Install using composer:

```
{
  "require": {
    "tmont/blueshift": "1.1.*"
  }
}
```

Blue Shift is PSR-4 compliant, so the following will setup autoloading once you've `composer install`'d:

```
require_once 'vendor/autoload.php';
```

Usage
-----

[](#usage)

Some example objects:

```
interface MyInterface {}

class MyType implements MyInterface {
  public function __construct(MyOtherType $type) {
    $this->type = $type;
  }
}

class MyOtherType {
  public function __construct($foo) {
    $this->foo = $foo;
  }
}
```

Registering a type and an instance:

```
$container = new Tmont\BlueShift\Container();
$container
  ->registerType('MyType', 'MyType')
  ->registerInstance('MyOtherType', new MyOtherType('bar'));

$myType = $container->resolve('MyType');
echo $myType->type->foo; // 'bar'
```

Registering a mapped type (interface -&gt; implementation):

```
$container = new Tmont\BlueShift\Container();
$container
  ->registerType('MyInterface', 'MyType')
  ->registerInstance('MyOtherType', new MyOtherType('bar'));

$myType = $container->resolve('MyInterface');
echo $myType instanceof MyInterface; // true
echo $myType instanceof MyClass; // true
```

Proxies and interception using [Phroxy](https://github.com/tmont/phroxy):

```
use Tmont\Phroxy\Interceptor;
use Tmont\Phroxy\InterceptionContext;

class MyInterceptableClass {
	public function foo() {
		return 'intercepted!';
	}
}

class MyInterceptor implements Interceptor {
	public function onBeforeMethodCall(InterceptionContext $context) {
		$context->setReturnValue('not foo');
	}

	public function onAfterMethodCall(InterceptionContext $context) {}
}

$container = new Tmont\BlueShift\Container();
$container
  ->registerType('MyInterceptableClass', 'MyInterceptableClass')
  ->proxyType('MyInterceptableClass')
  ->registerInterceptor(new MyInterceptor(), function(ReflectionMethod $method) {
	    return $method->getDeclaringClass()->getName() === 'MyInterceptableClass' &&
	        $method->getName() === 'foo';
    });

$obj = $container->resolve('MyInterceptableClass');
echo $obj->foo(); // 'intercepted!'
```

The container can also resolve anything you give it, even if you don't explicitly create a mapping, provided the type is instantiable.

```
class Nope {
	private function __construct() {}
}

class Yup {}

$container = new Tmont\BlueShift\Container();
$container->resolve('Yup'); //no probalo
$container->resolve('Nope'); //throws InvalidConstructorException
```

Development
-----------

[](#development)

```
git clone git@github.com:tmont/blueshift.git
cd blueshift
composer install
vendor/bin/phpunit
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

4494d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9cb8047aac36e053ac854aa3235d075dcdff2492e6728ec5125f971041780730?d=identicon)[tmont](/maintainers/tmont)

---

Top Contributors

[![tmont](https://avatars.githubusercontent.com/u/188562?v=4)](https://github.com/tmont "tmont (24 commits)")

---

Tags

containerdependencyinjectioncontrolinversion

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tmont-blueshift/health.svg)

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

###  Alternatives

[league/container

A fast and intuitive dependency injection container.

86387.8M343](/packages/league-container)[miladrahimi/phpcontainer

Dependency injection (IoC) container for PHP projects

1322.7k2](/packages/miladrahimi-phpcontainer)[capsule/di

A PSR-11 compliant autowiring dependency injection container.

2857.5k2](/packages/capsule-di)

PHPackages © 2026

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