PHPackages                             okeyaki/pimple-di - 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. okeyaki/pimple-di

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

okeyaki/pimple-di
=================

Integrates DI functionality with Pimple.

1.0.1(8y ago)031MITPHP

Since Jun 29Pushed 8y agoCompare

[ Source](https://github.com/okeyaki/pimple-di)[ Packagist](https://packagist.org/packages/okeyaki/pimple-di)[ RSS](/packages/okeyaki-pimple-di/feed)WikiDiscussions master Synced 3w ago

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

Pimple DI
=========

[](#pimple-di)

Pimple DI integrates DI functionality with [Pimple](http://pimple.sensiolabs.org/).

Features
--------

[](#features)

- Integrating DI (*constructor Injection*) functionality with Pimple.
- Easy to use.

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

[](#installation)

Add `okeyaki/pimple` to your `composer.json`:

```
$ composer require okeyaki/pimple-di

```

Usage
-----

[](#usage)

At first, create a sub-class of `Pimple\Container` and mixin `Okeyaki\Pimple\DiTrait`:

```
class Container extends \Pimple\Container
{
    use \Okeyaki\Pimple\DiTrait;
}
```

Then, create an instance of the class:

```
$container = new Container();
```

### Constructor Injection

[](#constructor-injection)

Pimple DI resolves dependencies automatically by the classes of constructor parameters:

```
class Foo
{
}

class Bar
{
    private $foo;

    public function __construct(Foo $foo)
    {
        $this->foo = $foo;
    }

    public function foo()
    {
        return $this->foo;
    }
}

$foo = $container[Foo::class];

$bar = $contaienr[Bar::class];
$bar->foo();
```

### Class Binding

[](#class-binding)

You can bind classes to an existing ID:

```
class Foo
{
}

$container['foo'] = function () {
    return new Foo();
};

$container->bind(Foo::class, 'foo');

$foo = $container[Foo::class];
```

This is useful on using [Silex](https://silex.sensiolabs.org/) proprietary or third-party providers.

### Instanciation

[](#instanciation)

You can instanciate a class and resolve its dependencies automatically:

```
class Foo
{
}

class Bar
{
    private $foo;

    public function __construct(Foo $foo)
    {
        $this->foo = $foo;

        $this->name = $name;
    }

    public function foo()
    {
        return $this->foo;
    }
}

$bar = $container->make(Bar::class);
$bar->foo();

```

If a constructor has unresolvable parameters:

```
class Bar
{
    private $foo;

    private $baz;

    public function __construct(Foo $foo, $baz)
    {
        $this->foo = $foo;

        $this->baz = $baz;
    }

    public function foo()
    {
        return $this->foo;
    }

    public function baz()
    {
        return $this->baz;
    }
}

$bar = $container->make(Bar::class, [
    'baz' => 'baz',
]);

$bar->foo();
$bar->baz();

```

Examples
--------

[](#examples)

### Integrating with Silex

[](#integrating-with-silex)

```
class App extends \Silex\Application
{
    use \Okeyaki\Pimple\DiTrait;
}

```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity64

Established project with proven stability

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 ~174 days

Total

2

Last Release

3111d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7233643e9ea218cc3c03201d6e4a1d8ce44a4046a902ddfea91174f03e545f81?d=identicon)[okeyaki](/maintainers/okeyaki)

### Embed Badge

![Health badge](/badges/okeyaki-pimple-di/health.svg)

```
[![Health](https://phpackages.com/badges/okeyaki-pimple-di/health.svg)](https://phpackages.com/packages/okeyaki-pimple-di)
```

###  Alternatives

[oat-sa/tao-core

TAO core extension

66140.1k108](/packages/oat-sa-tao-core)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73147.2k29](/packages/jaxon-php-jaxon-core)[ckfinder/ckfinder-laravel-package

CKFinder 3 package for Laravel

159517.6k67](/packages/ckfinder-ckfinder-laravel-package)[ckfinder/ckfinder-symfony-bundle

CKFinder bundle for Symfony

42448.0k](/packages/ckfinder-ckfinder-symfony-bundle)[inpsyde/wp-app-container

DI Container and related tools to be used at website level.

41267.6k](/packages/inpsyde-wp-app-container)[rockettheme/toolbox

RocketTheme Toolbox Library

22535.0k4](/packages/rockettheme-toolbox)

PHPackages © 2026

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