PHPackages                             onoi/callback-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. onoi/callback-container

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

onoi/callback-container
=======================

A very simple callback container/builder library

2.0.0(9y ago)1537.6k↑98.8%3[1 issues](https://github.com/onoi/callback-container/issues)[1 PRs](https://github.com/onoi/callback-container/pulls)3GPL-2.0+PHPPHP &gt;=5.5

Since Sep 8Pushed 8y ago1 watchersCompare

[ Source](https://github.com/onoi/callback-container)[ Packagist](https://packagist.org/packages/onoi/callback-container)[ Docs](https://github.com/onoi/callback-container)[ RSS](/packages/onoi-callback-container/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (3)

Callback container
==================

[](#callback-container)

[![Build Status](https://camo.githubusercontent.com/2952ced009ecb681b2ca2fed795ed75cb7bd1d96920cb329ff9dc6b171a0e888/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6f6e6f692f63616c6c6261636b2d636f6e7461696e65722e7376673f6272616e63683d6d6173746572)](http://travis-ci.org/onoi/callback-container)[![Code Coverage](https://camo.githubusercontent.com/bfff64efbc3e7236994570d6baf98275f435d434b380309313dc467ad2cba9d5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f6e6f692f63616c6c6261636b2d636f6e7461696e65722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/onoi/callback-container/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/dc72f55bd6fccbe5173985aacf4b57bcad54e9d98a2c5b84a269d8af7e9d46c0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f6e6f692f63616c6c6261636b2d636f6e7461696e65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/onoi/callback-container/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/ba539c0a6d81734ab9e0ddda2e593ce990944ac7a263c2093d76eda15231e8cb/68747470733a2f2f706f7365722e707567782e6f72672f6f6e6f692f63616c6c6261636b2d636f6e7461696e65722f76657273696f6e2e706e67)](https://packagist.org/packages/onoi/callback-container)[![Packagist download count](https://camo.githubusercontent.com/ce3d6caeb6deb50864bce41fb6772e368df00931086cef85748628f0a10206a3/68747470733a2f2f706f7365722e707567782e6f72672f6f6e6f692f63616c6c6261636b2d636f6e7461696e65722f642f746f74616c2e706e67)](https://packagist.org/packages/onoi/callback-container)[![Dependency Status](https://camo.githubusercontent.com/fd3ff24891cf46f41489c95314e8543ed1afc99151db62bffc8bd54cd721bea9/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f6f6e6f693a63616c6c6261636b2d636f6e7461696e65722f62616467652e706e67)](https://www.versioneye.com/php/onoi:callback-container)

A simple object instantiator to lazy load registered callback handlers. Part of the code base has been extracted from [Semantic MediaWiki](https://github.com/SemanticMediaWiki/SemanticMediaWiki/) and is now being deployed as independent library.

Requirements
------------

[](#requirements)

- PHP 5.5
- HHVM 3.5 or later

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

[](#installation)

The recommended installation method for this library is to add the dependency to your [composer.json](https://getcomposer.org/).

```
{
	"require": {
		"onoi/callback-container": "~2.0"
	}
}
```

Usage
-----

[](#usage)

```
use Onoi\CallbackContainer\CallbackContainerFactory;

$callbackContainerFactory = new CallbackContainerFactory();
$containerBuilder = $callbackContainerFactory->newCallbackContainerBuilder();

$containerBuilder->registerCallbackContainer( ... );

$service = $containerBuilder->create( ... );
$service = $containerBuilder->singleton( ... );
```

This [document](/docs/usage.md) contains detailed examples on how to use the `CallbackContainerFactory`and `ContainerBuilder`.

Contribution and support
------------------------

[](#contribution-and-support)

If you want to contribute work to the project please subscribe to the developers mailing list and have a look at the [contribution guidelinee](/CONTRIBUTING.md). A list of people who have made contributions in the past can be found [here](https://github.com/onoi/callback-container/graphs/contributors).

- [File an issue](https://github.com/onoi/callback-container/issues)
- [Submit a pull request](https://github.com/onoi/callback-container/pulls)

### Tests

[](#tests)

The library provides unit tests that covers the core-functionality normally run by the [continues integration platform](https://travis-ci.org/onoi/callback-container). Tests can also be executed manually using the `composer phpunit` command from the root directory.

Release notes
-------------

[](#release-notes)

- 2.0.0 (2017-02-18)
- Requires PHP 5.5+
- Added `CallbackContainerFactory`
- Added `CallbackContainerBuilder::registerAlias`
- Added `CallbackContainerBuilder::registerFromFile` to allow loading callback definitions from a file
- 1.1.0 (2016-04-30)
- Fixed issue in `registeredObject` for when a singleton override contained a `null` argument
- Deprecated the `CallbackLoader` interface in favour of the `CallbackInstantiator` interface
- Deprecated the `NullCallbackLoader` class in favour of the `NullCallbackInstantiator` class
- 1.0.0 (2015-09-08)
- Added the `CallbackContainer` and `CallbackLoader` interface
- Added the `DeferredCallbackLoader` and `NullCallbackLoader` implementation

License
-------

[](#license)

[GNU General Public License 2.0 or later](https://www.gnu.org/copyleft/gpl.html).

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 95.5% 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 ~176 days

Total

4

Last Release

3422d ago

Major Versions

1.1.0 → 2.x-dev2016-11-26

PHP version history (2 changes)1.0.0PHP &gt;=5.3.2

2.x-devPHP &gt;=5.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/372f9bc1233d5518b9522cb681210a8de2765a3a9bbde20138f6ad5332a411ca?d=identicon)[mwjames](/maintainers/mwjames)

![](https://www.gravatar.com/avatar/511b3dbc1a73ad7b69118e540b16c8bcc2ac5f923022b94aa61a8d71af612f9c?d=identicon)[onoi](/maintainers/onoi)

---

Top Contributors

[![mwjames](https://avatars.githubusercontent.com/u/1245473?v=4)](https://github.com/mwjames "mwjames (21 commits)")[![kghbln](https://avatars.githubusercontent.com/u/1104078?v=4)](https://github.com/kghbln "kghbln (1 commits)")

---

Tags

containerdependency-injectioncontainer

### Embed Badge

![Health badge](/badges/onoi-callback-container/health.svg)

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

###  Alternatives

[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k373.5M3.3k](/packages/symfony-cache)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[dvdoug/boxpacker

An implementation of the 3D (actually 4D) bin packing/knapsack problem (aka creating parcels by putting items into boxes)

6562.9M25](/packages/dvdoug-boxpacker)[api-platform/metadata

API Resource-oriented metadata attributes and factories

275.0M219](/packages/api-platform-metadata)[cspray/annotated-container

Create Dependency Injection containers configured with PHP8 Attributes.

421.3k5](/packages/cspray-annotated-container)

PHPackages © 2026

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