PHPackages                             buffalokiwi/buffalotools\_ioc - 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. buffalokiwi/buffalotools\_ioc

ActiveLibrary

buffalokiwi/buffalotools\_ioc
=============================

IOC / Service Locator for PHP 8

v1.0.12(4y ago)0241MITPHPPHP ^8.0

Since Mar 31Pushed 4y ago1 watchersCompare

[ Source](https://github.com/SixArmDonkey/buffalotools_ioc)[ Packagist](https://packagist.org/packages/buffalokiwi/buffalotools_ioc)[ Docs](https://github.com/SixArmDonkey/buffalotools_ioc)[ RSS](/packages/buffalokiwi-buffalotools-ioc/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (14)Used By (1)

BuffaloKiwi IOC / Service Locator
=================================

[](#buffalokiwi-ioc--service-locator)

A fast, simple and straightforward inversion of control / service locator library for PHP 7.4.

MIT License

---

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

[](#installation)

```
composer require buffalokiwi/buffalotools_ioc

```

---

The Basics
----------

[](#the-basics)

This container will maintain a single reference to any registered service.

1. Services are registered by calling addInterface(). The supplied closure contains the call to new class().
2. Services are instantiated on demand, and no instance is created unless newInstance() is called.
3. Calling getIntance() will call newInstance() once and cache the result.
4. Subsequent calls to getIntance() will return the cached instance.
5. This container is not meant to be passed around to various classes.
6. All services should be registered in a single location (composition root), and should be automatically injected into constructors via some router.
7. When constructing the container, specifying strict mode will test that the instance returned by the closure supplied to addInstance() matches the interface supplied to addInstance() when calling newInstance().

Example
-------

[](#example)

```
//..Create the IOC container
$ioc = new IOC();

//..Add some interface to the container, and supply a factory for creating new instances
$ioc->addInterface( \namespace\to\SomeAmazingClass::class, function() {
  return new SomeAmazingClass();
});

//..Retrieve the class instance by supplying the same interface or class name as supplied to addInterface()
$amazing = $ioc->getInstance( \namespace\to\SomeAmazingClass::class );
```

**Note**: Using the ::class suffix is a shortcut to the fully namespaced class name, and will NOT trigger the autoloader.

**Note 2**: DO NOT add "use" statements when registering objects with the container. This WILL trigger the autoloader.

**Always use the fully namespaced class or interface name (preferably an interface).**

Autowire method
---------------

[](#autowire-method)

The container contains a method autowire(). This will attempt to automatically determine values for some class constructor. Variables can be passed in arg#2 as a named map.

Argument Mapper
---------------

[](#argument-mapper)

An instance of IArgumentMapper may be supplioed to the constructor of class IOC. When calling autowire(), the mapper is first checked for a class/interface name matching the one supplied to autowire(). If found, the arguments contained within the mapper are merged with the $args array supplied to autowire() with $args taking precedence. This can be used to move certain configuration elements to a different location.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

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

Recently: every ~11 days

Total

13

Last Release

1725d ago

PHP version history (3 changes)v1.0.0PHP &gt;=7.4.0

v1.0.3PHP ^7.4 || ^8.0

v1.0.4PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/26635705c76bff0d1c6b96c4cc92ba9e59a57b7723122ac0c0690f8742310e22?d=identicon)[SixArmDonkey](/maintainers/SixArmDonkey)

---

Top Contributors

[![SixArmDonkey](https://avatars.githubusercontent.com/u/7980059?v=4)](https://github.com/SixArmDonkey "SixArmDonkey (22 commits)")

---

Tags

iocservice locator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/buffalokiwi-buffalotools-ioc/health.svg)

```
[![Health](https://phpackages.com/badges/buffalokiwi-buffalotools-ioc/health.svg)](https://phpackages.com/packages/buffalokiwi-buffalotools-ioc)
```

###  Alternatives

[php-di/php-di

The dependency injection container for humans

2.8k48.9M994](/packages/php-di-php-di)[nette/di

💎 Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP features.

92140.6M1.4k](/packages/nette-di)[rdlowrey/auryn

Auryn is a dependency injector for bootstrapping object-oriented PHP applications.

7262.2M76](/packages/rdlowrey-auryn)[level-2/dice

A minimalist Dependency injection container (DIC) for PHP. Please note: 3.0+ is only compatible with PHP 7.0. The 2.0 branch is compatbile with PHP 5.6.

437730.3k17](/packages/level-2-dice)[acclimate/container

Provides adapters for various third-party service containers.

219390.6k15](/packages/acclimate-container)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)

PHPackages © 2026

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