PHPackages                             ytake/hh-container - 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. ytake/hh-container

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

ytake/hh-container
==================

simple light weight service location / dependency injection container

1.1.0(7y ago)2569MITHack

Since Oct 31Pushed 7y ago2 watchersCompare

[ Source](https://github.com/ytake/hh-container)[ Packagist](https://packagist.org/packages/ytake/hh-container)[ RSS](/packages/ytake-hh-container/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (7)Dependencies (7)Versions (11)Used By (0)

This Project Has Been Deprecated
================================

[](#this-project-has-been-deprecated)

HH-Container
============

[](#hh-container)

simple light weight service location / dependency injection container

[![Build Status](https://camo.githubusercontent.com/7f0944b14e0cefd1e720d5ac25ac4ed42790935c87cae107e176717c820ee687/68747470733a2f2f7472617669732d63692e6f72672f7974616b652f68682d636f6e7461696e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ytake/hh-container)

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

[](#installation)

```
$ hhvm $(which composer) require ytake/hh-container
```

```
"require": {
  "hhvm": ">=3.24",
  "ytake/hh-container": "^1.0"
},
```

Usage
-----

[](#usage)

```
$container = new \Ytake\HHContainer\FactoryContainer();
$container->set('testing', $container ==> 'testing');
$container->get('testing'); // return string
```

Singleton or Prototype
----------------------

[](#singleton-or-prototype)

default *prototype*

### SINGLETON

[](#singleton)

```
$container = new \Ytake\HHContainer\FactoryContainer();
$container->set('scope:singleton', $container ==> new \stdClass(), \Ytake\HHContainer\Scope::Singleton);
```

### PROTOTYPE

[](#prototype)

```
$container = new \Ytake\HHContainer\FactoryContainer();
$container->set('scope:prototype', $container ==> new \stdClass(), \Ytake\HHContainer\Scope::Prototype);
```

Dependency Injection
--------------------

[](#dependency-injection)

### set parameters

[](#set-parameters)

sample class

```
final class MessageClass {
  public function __construct(
    protected string $message
  ) {}

  public function message(): string {
    return $this->message;
  }
}

final class MessageClient {
  public function __construct(
    protected MessageClass $message
  ) {}

  public function message(): MessageClass {
    return $this->message;
  }
}
```

### Inject

[](#inject)

```
$container = new \Ytake\HHContainer\FactoryContainer();
$container->set('message.class', $container ==> new MessageClass('testing'));
$container->set(MessageClient::class, $container ==> {
  $instance = $container->get('message.class');
  invariant($instance instanceof MockMessageClass, 'error');
  new MessageClient($instance);
});
$instance = $container->get(MessageClient::class);
```

### callable

[](#callable)

returns the value of a callable with parameters supplied at calltime.

```
final class TestingInvokable {
  public function __invoke(FactoryContainer $container): int {
    return 1;
  }
}

$container = new \Ytake\HHContainer\FactoryContainer();
$container->set(TestingInvokable::class, $container ==>
  $container->callable(
    new \Ytake\HHContainer\Invokable(
      new TestingInvokable(), '__invoke', $container
    )
  )
);
```

Use modules
-----------

[](#use-modules)

```
use Ytake\HHContainer\ServiceModule;
use Ytake\HHContainer\FactoryContainer;

class ExampleModule extends ServiceModule {

  public function provide(FactoryContainer $container): void {
    $container->set('example', $container ==> new \stdClass());
  }
}
```

```
$container = new \Ytake\HHContainer\FactoryContainer();
$container->register(ExampleModule::class);
$container->lockModule();
```

Service Factory
---------------

[](#service-factory)

```
use Ytake\HHContainer\Scope;
use Ytake\HHContainer\ServiceFactory;
use Ytake\HHContainer\FactoryContainer;
use Ytake\HHContainer\FactoryInterface;

class StringFactory implements FactoryInterface {
  const type T = string;
  public function provide(FactoryContainer $_container): StringFactory::T {
    return 'testing';
  }
  public function scope(): Scope {
    return Scope::Singleton;
  }

  public function name(): string {
    return 'testing'
  }
}

$factory = new ServiceFactory(new FactoryContainer());
$factory->registerFactory(new StringFactory());
$factory->create('testing');
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity69

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

Every ~56 days

Recently: every ~68 days

Total

7

Last Release

2823d ago

Major Versions

0.5.2 → 1.0.22018-08-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/47817f3dd2890864096bd77ee772ec46061432f128988ca23939b0ca486d7bc3?d=identicon)[ytake](/maintainers/ytake)

---

Top Contributors

[![ytake](https://avatars.githubusercontent.com/u/4454078?v=4)](https://github.com/ytake "ytake (41 commits)")

---

Tags

containerhackhacklanghhvmserviceloadercontainerhhvmhack

### Embed Badge

![Health badge](/badges/ytake-hh-container/health.svg)

```
[![Health](https://phpackages.com/badges/ytake-hh-container/health.svg)](https://phpackages.com/packages/ytake-hh-container)
```

PHPackages © 2026

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