PHPackages                             zap/injector - 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. [Framework](/categories/framework)
4. /
5. zap/injector

ActiveLibrary[Framework](/categories/framework)

zap/injector
============

A simple Dependency Injector for PHP 5.4+

0.3.0(12y ago)045MITPHPPHP &gt;=5.4.0

Since Mar 10Pushed 11y ago3 watchersCompare

[ Source](https://github.com/imarc/zap-injector)[ Packagist](https://packagist.org/packages/zap/injector)[ Docs](http://github.com/imarc/zap-injector)[ RSS](/packages/zap-injector/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (6)Used By (0)

Zap\\Injector
=============

[](#zapinjector)

[![Build Status](https://camo.githubusercontent.com/8c8cc135ab060fe997fc4b43af18525c80eebbe6e4551158932b17dcc3c1eb0c/68747470733a2f2f7472617669732d63692e6f72672f696d6172632f7a61702d696e6a6563746f722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/imarc/zap-injector)

A simple dependency injection library

The Zap Injector looks to find the middle ground between the simplicity offered by tiny service locators like Pimple and the real dependency injection libraries like PHP-DI provide.

Why would I use this?
---------------------

[](#why-would-i-use-this)

- It handles resolving dependencies and their configuration in order.
- It allows for dependencies to only be loaded on demand.
- It allows configuration to only be loaded on demand, and to be configured from anywhere.
- If you register under parent classes or interfaces, it decouples modules from their dependencies.

Usage:
------

[](#usage)

```
$injector = new \iMarc\Zap\Injector();

// Register a factory under a class or interface name:
$injector->register('Request', function() {
	return new Request();
});

// Or Register a specific instance:
$injector->register(Request::createFromGlobals());

// Or register a class to simply be constructed:
$injector->register('Session');

// Invoke a callable, and Injector will fill in the dependencies:
$returnValue = $injector->invoke(function(Request $req, Session $sess) {
	return array($req, $sess);
});

// Similarly, construct an instance of a class with dependencies:
$instance = $injector->create('some\class');
```

Also, Injector has an `extend` method. Extensions are invoked immediately after a new instance is constructed from a factory or from a classname:

```
$injector->extend('Request', function(Request $req) {
	$req->setSomethingImportant(true);
});
```

Changelog
---------

[](#changelog)

### 0.x

[](#0x)

#### 0.3.0

[](#030)

- Major refactoring and code cleanup.

#### 0.2.0

[](#020)

- Added -&gt;register(), removed -&gt;addFactory(), -&gt;addInstance(), and -&gt;addClass()
- Renamed -&gt;remove() to -&gt;unregister()
- Other refactoring

#### 0.1.1

[](#011)

- Added -&gt;extend() method, similar to Pimple. Callbacks configured with -&gt;extend() are called after an instance is created by a factory.

#### 0.1.0

[](#010)

- Initial Release, full of bugs

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.3% 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 ~5 days

Total

4

Last Release

4430d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/00725533df5fd021ac93639028725bf46bef78f6d924618a987b9bfd5c32c3eb?d=identicon)[jeffturcotte](/maintainers/jeffturcotte)

![](https://www.gravatar.com/avatar/4c423d4aa457201693aadc0ffd67895f3383709e89c66547949d65a37123ee22?d=identicon)[khamer](/maintainers/khamer)

---

Top Contributors

[![jeffturcotte](https://avatars.githubusercontent.com/u/65089?v=4)](https://github.com/jeffturcotte "jeffturcotte (22 commits)")[![khamer](https://avatars.githubusercontent.com/u/1452?v=4)](https://github.com/khamer "khamer (8 commits)")

---

Tags

dependency-injectiondi

### Embed Badge

![Health badge](/badges/zap-injector/health.svg)

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

###  Alternatives

[yiisoft/injector

PSR-11 compatible injector. Executes a callable and makes an instances by injecting dependencies from a given DI container.

942.8M38](/packages/yiisoft-injector)[mouf/mouf

The Mouf PHP framework: an open-source PHP framework providing an easy way to download, install, use and reuse components, with a graphical user interface.

55146.0k17](/packages/mouf-mouf)[mouf/pimple-interop

This project is a very simple extension to the Pimple microframework. It adds to Pimple compatibility with the container-interop APIs.

102.4M2](/packages/mouf-pimple-interop)[joomla/di

Joomla DI Package

15391.2k11](/packages/joomla-di)[mouf/picotainer

This package contains a really minimalist dependency injection container compatible with container-interop.

16189.8k11](/packages/mouf-picotainer)

PHPackages © 2026

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