PHPackages                             codejet/bucket - 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. codejet/bucket

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

codejet/bucket
==============

A light container-interop compatible DI Container object.

1.0.0(8y ago)0675MITPHP ^7.0

Since Dec 18Compare

[ Source](https://github.com/CodeJetNet/bucket)[ Packagist](https://packagist.org/packages/codejet/bucket)[ RSS](/packages/codejet-bucket/feed)WikiDiscussions Synced yesterday

READMEChangelog (2)Dependencies (3)Versions (4)Used By (0)

Bucket
======

[](#bucket)

```
     .=======.
    /         \
   /   _____   \
  /.-'"     "`-.\
 [(             )]
  |`-.._____..-'|
  |             |
  |             |
  |   bucket    |
  \             /
   `-.._____..-'

```

[![Latest Version on Packagist](https://camo.githubusercontent.com/c11447cbe7011aef2eb7c5f6d07823b0464be44fa32dea296ca55c67e2e6e5bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f64656a65742f6275636b65742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codejet/bucket)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/9c1bafe89be20b73b2283fb73ff227e2cd7aa2498ef6c7162900fe12ac44a6c1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f436f64654a65744e65742f6275636b65742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/CodeJetNet/bucket)[![Coverage Status](https://camo.githubusercontent.com/6b4b934ddd999d096abc12f17645fa6060d8f2822e957ddc37191ffdfc3092ac/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f436f64654a65744e65742f6275636b65742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/CodeJetNet/bucket/code-structure)[![Quality Score](https://camo.githubusercontent.com/09a03cfc8958f4457e9d0ad56290d940abdc22c0dcca6689a89b2f9a1270bb84/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f436f64654a65744e65742f6275636b65742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/CodeJetNet/bucket)[![Total Downloads](https://camo.githubusercontent.com/f41867d083d2535a828c7b901121dd14cdf67d1e17a60baa4846366ee5a073ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f64656a65742f6275636b65742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codejet/bucket)

A convenient [container-interop](https://github.com/container-interop/container-interop) compatible DI container object.

Easy to use, easy to understand and inherently easy to extend.

Install
-------

[](#install)

Via Composer

```
$ composer require codejet/bucket
```

Usage
-----

[](#usage)

### Creating a bucket

[](#creating-a-bucket)

```
$bucket = new CodeJet\Bucket\Bucket();
```

### Adding Values

[](#adding-values)

Using a string as the key, pass any value that is not a `\Closure` and it will be stored as-is.

```
$bucket->add('value-id', 'The value of the value.');
```

### Adding Factories

[](#adding-factories)

Using a string as the key and passing a `\Closure` as the value will store a factory. The Closure may accept `\Interop\Container\ContainerInterface` as it's only argument. The bucket will pass itself (or the assigned delegate) in to the factory when `$bucket->get('service-id')` is called the first time and it will store the returned data as the value for subsequent requests for the same id.

```
$bucket->add(
    'service-id',
    function (\Interop\Container\ContainerInterface $bucket) {
        return new \stdClass();
    }
);
```

### Retrieving Items

[](#retrieving-items)

```
var_dump($bucket->has('value-id')); // bool(true)
var_dump($bucket->get('value-id')); // string(23) "The value of the value."

var_dump($bucket->has('service-id')); // bool(true)
var_dump($bucket->get('service-id')); // class stdClass#4 (0) { }
```

### Delegate lookup feature

[](#delegate-lookup-feature)

The [container-interop delegate lookup standard](https://github.com/container-interop/container-interop/blob/master/docs/Delegate-lookup.md) provides a means through which a container may use an alternate container for dependency injection purposes.

```
$delegateLookupContainer = new \League\Container\Container();
$delegateLookupContainer->add('importantSetting', 'This value is only found in the delegate container.');

$bucket = new \CodeJet\Bucket\Bucket();
$bucket->setDelegateContainer($delegateLookupContainer);
$bucket->add(
    'service-id',
    function (\Interop\Container\ContainerInterface $container) {
        // The factory Closure is passed the delegate lookup container.
        return $container->get('importantSetting');
    }
);

var_dump($bucket->get('service-id')); // string(51) "This value is only found in the delegate container."
var_dump($bucket->has('importantSetting')); // bool(false)
```

Testing
-------

[](#testing)

```
$ composer test
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity60

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

Total

2

Last Release

3255d ago

Major Versions

0.1.0 → 1.0.02017-08-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2b92b5a53a8e8f3b2e4065273a99f31fe19b950eb058cd1bd620cde48399420?d=identicon)[Houghtelin](/maintainers/Houghtelin)

---

Tags

containerdibucketcodejet

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/codejet-bucket/health.svg)

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

2.9k55.5M1.2k](/packages/php-di-php-di)[league/container

A fast and intuitive dependency injection container.

86894.4M426](/packages/league-container)[aura/di

A serializable dependency injection container with constructor and setter injection, interface and trait awareness, configuration inheritance, and much more.

352982.2k60](/packages/aura-di)[league/tactician-container

Tactician integration for any container implementing PSR-11

7710.4M24](/packages/league-tactician-container)[mrclay/props-dic

Props is a simple DI container that allows retrieving values via custom property and method names

3512.7M3](/packages/mrclay-props-dic)[slince/di

A flexible dependency injection container

20272.1k6](/packages/slince-di)

PHPackages © 2026

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