PHPackages                             inxilpro/zit - 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. inxilpro/zit

Abandoned → [syberisle/zit](/?search=syberisle%2Fzit)ArchivedLibrary[PSR &amp; Standards](/categories/psr-standards)

inxilpro/zit
============

Zit is a simple dependency injector based heavily on Pimple. It aims to provide the same simplicity as Pimple while offering a slightly more robust object interface.

3.0.0(10y ago)26796MITPHPPHP &gt;=5.4.0

Since Jul 25Pushed 4y ago1 watchersCompare

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

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

Zit
===

[](#zit)

[![Build Status](https://camo.githubusercontent.com/4c850ec8ee1f375d467583864b310230dcfd4af85535edd5260645c398820f8e/68747470733a2f2f7472617669732d63692e6f72672f696e78696c70726f2f5a69742e737667)](https://travis-ci.org/inxilpro/Zit)[![Packagist Version](https://camo.githubusercontent.com/2dc889b5d91dc55204faa19fb06e561742fe7814d4f10fe429f3a84c7c42d205/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e78696c70726f2f7a69742e737667)](https://packagist.org/packages/inxilpro/zit)[![GitHub Stars](https://camo.githubusercontent.com/a7355fc61a8af1009d3099d42c601e7cec77c486f33b6b0300921e2d761887ed/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f696e78696c70726f2f5a69742e737667)](https://github.com/inxilpro/Zit/stargazers)[![PHP 5.4+](https://camo.githubusercontent.com/8c0f60d1723a338ee0f3b5b125c850929c83d5a0c48322b0ea62c3c154c2750f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344352e342d79656c6c6f77677265656e2e737667)](https://secure.php.net/releases/5_4_0.php)

Zit is a simple dependency injector based heavily on Pimple. It aims to provide the same simplicity as Pimple while offering a slightly more robust object interface.

⚠️ Use `syberisle/zit` Instead
------------------------------

[](#️-use-syberislezit-instead)

This package has been updated and replaced by [`syberisle/zit`](https://github.com/SyberIsle/Zit). Please upgrade to that to get the latest updates and improvements.

Original README
===============

[](#original-readme)

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

[](#installation)

Zit is available via Composer:

```
composer require inxilpro/zit
```

Usage
-----

[](#usage)

Zit is simple to use. Like Pimple, objects are defined through anonymous functions that return an instance of the object:

```
$container = new \Zit\Container();
$container->set('auth', function() {
	return new Auth();
});
```

All instantiation functions are passed the container as the first argument, making dependency injection possible:

```
$container->set('auth', function($container) {
	return new Auth($container->get('db'));
});
```

Zit also provides convenient magic methods for setting instantiation functions:

```
$container->setAuth(function() { /* ... */ }); // Or:
$container->set_auth(function() { /* ... */ });
```

Getting Objects
---------------

[](#getting-objects)

Getting objects are as simple as:

```
$container->get('auth');
```

Or, if you prefer the shorthand:

```
$container->getAuth(); // Or:
$container->get_auth();
```

Getting Fresh Objects
---------------------

[](#getting-fresh-objects)

By default, all objects are shared in Zit. That is, once an object is created, that same exact object is returned for each additional `get()`. If you need a fresh object, you can do so with:

```
$container->fresh('auth'); // Or:
$container->freshAuth(); // Or:
$container->fresh_auth(); // Or:
$container->newAuth(); // Or:
$container->new_auth();
```

> Note that because the 'new' keyword is reserved, you can only use it if you're using the magic methods.

Constructor Parameters
----------------------

[](#constructor-parameters)

Sometimes you need to pass parameters to the constructor of an object, while still also injecting dependencies. Zit automatically passes all parameters on to your instantiation function:

```
$container->setUser(function($c, $id)) {
	$user = new User($id);
	$user->setDb($c->getDb());
	return $user;
});

$user = $container->newUser(1);

// Parameters are taken into account when caching results:
$user2 = $container->getUser(1); // $user2 === $user;
```

Storing Static Content
----------------------

[](#storing-static-content)

You can also use Zit to store strings/objects/etc. Just pass it instead of a generator:

```
$container->set('api_key', 'abcd1234567890');
$key = $container->get('api_key');
```

**Please note:** You must wrap callables with an instantiation function if you want the callable returned rather than the return value of the callable.

Custom Container
----------------

[](#custom-container)

Most projects will benefit from a custom container that sets up its own injection rules. This is as simple as extending Zit:

```
namespace MyApp\Di;

class Container extends \Zit\Container
{
	public function __construct()
	{
		$this->setAuth(function() { /* ... */ });
		$this->setUser(function() { /* ... */ });
	}
}
```

Change Log
----------

[](#change-log)

### Version 3.0.0

[](#version-300)

- Implemented [Container Interoperability](https://github.com/container-interop/container-interop). Zit was already `container-interop` compatible, but it now implements the interface and throws an exception that implements `Interop\Container\Exception\NotFoundException` when a item is not found. This exception extends `\InvalidArgumentException`, so 3.0.0 should be nearly 100% backwards-compatible, but I'm bumping the major version just in case.
- Dropped support for PHP 5.3
- Removed deprecated function `setParam`
- `setFactory()` now accepts any `callable` instead of specifically a `Closure`
- Fixed a typo in the exception message thrown from `__call` if a method does not exist
- `set()` is now fluent (returns the container for chaining)
- Switched to md4 hashing for speed improvements (we don't need the security of md5)
- Added DocBlocks throughout the code

### Version 2.0

[](#version-20)

- Removed the `setParam` method in favor of checking whether the parameter passed to `set` is callable.
- Added the "Factory" variant. This could cause backwards compatibility issues if you have set up objects that end with the word "factory".
- Updated the `delete` method so that it clears out objects, callbacks, and factories, which could have some abnormal BC issues as well.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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 ~594 days

Total

2

Last Release

3716d ago

Major Versions

2.0.0 → 3.0.02016-03-11

PHP version history (2 changes)2.0.0PHP &gt;=5.3.0

3.0.0PHP &gt;=5.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21592?v=4)[Chris Morrell](/maintainers/inxilpro)[@inxilpro](https://github.com/inxilpro)

---

Top Contributors

[![inxilpro](https://avatars.githubusercontent.com/u/21592?v=4)](https://github.com/inxilpro "inxilpro (36 commits)")[![jhoughtelin](https://avatars.githubusercontent.com/u/6137941?v=4)](https://github.com/jhoughtelin "jhoughtelin (4 commits)")

---

Tags

containerdependencydependency-injectiondipimplezit

### Embed Badge

![Health badge](/badges/inxilpro-zit/health.svg)

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

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

A fast and intuitive dependency injection container.

86387.8M343](/packages/league-container)[aura/di

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

356968.3k58](/packages/aura-di)[mrclay/props-dic

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

3611.7M3](/packages/mrclay-props-dic)[capsule/di

A PSR-11 compliant autowiring dependency injection container.

2857.5k2](/packages/capsule-di)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)

PHPackages © 2026

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