PHPackages                             selvinortiz/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. selvinortiz/zit

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

selvinortiz/zit
===============

Tiny dependency management library for PHP

v1.0.1(10y ago)63803MITPHPPHP &gt;=5.4

Since Aug 21Pushed 6y ago2 watchersCompare

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

READMEChangelog (5)Dependencies (1)Versions (11)Used By (0)

[![Zit](Zit.png)](Zit.png)

[![Build Status](https://camo.githubusercontent.com/2c23afdc0e36ef8bf6e850a2fc9c463d0b53b99c15382f880cbf66a07a485730/68747470733a2f2f7472617669732d63692e6f72672f73656c76696e6f7274697a2f7a69742e706e67)](https://travis-ci.org/selvinortiz/zit)[![Total Downloads](https://camo.githubusercontent.com/add6ea6cc4beeba6cf667efda52e16e984b1fbc2a35fd4abc0d86972551567ed/68747470733a2f2f706f7365722e707567782e6f72672f73656c76696e6f7274697a2f7a69742f642f746f74616c2e706e67)](https://packagist.org/packages/selvinortiz/zit)[![Latest Stable Version](https://camo.githubusercontent.com/ba8df9d79ef937ab3586a7a9ea4c5fc474c4e6c44cfe3b5b35d8959ea26fd34b/68747470733a2f2f706f7365722e707567782e6f72672f73656c76696e6f7274697a2f7a69742f762f737461626c652e706e67)](https://packagist.org/packages/selvinortiz/zit)

### Description

[](#description)

> **Zit** is a tiny dependency injection library inspired by [Pimple](https://github.com/fabpot/Pimple) and written by [Selvin Ortiz](https://selvinortiz.com)

### Requirements

[](#requirements)

- PHP 5.4+
- [Composer](http://getcomposer.org) and [selvinortiz/zit](https://packagist.org/packages/selvinortiz/zit)

### Install

[](#install)

```
composer require selvinortiz/zit
```

### Test

[](#test)

```
sh spec.sh
```

### Usage

[](#usage)

> Dependency management is a difficult topic to explain but essentially, **Zit** lets you stuff things into it that you can pop out later throughout your application.

```
// Make an instance
$app = Zit::make();

// Stash a config object
$app->stash('config', new Config(['usr' => 'root', 'pwd' => 'secret']));

// Bind a session generator
$app->bind('session', function() {
    return new Session();
});

// Bind a database generator
$app->bind('db', function($app) {
    return new Db($app->config->usr, $app->config->pwd);
});

// Extend your $app with new functionality
$app->extend('end', function($app) {
    $app->db->close();
    $app->session->destroy();
});

// Finish
$app->end();
```

> You can also use **Zit** without making a new instance, the *static way* if you will.

```
// Stash a config object
Zit::stash('config', new Config(['usr' => 'root', 'pwd' => 'secret']));

// Bind a session generator
Zit::bind('session', function() {
    return new Session();
});

// Bind a database generator
Zit::bind('db', function($zit) {
    return new Db($zit->config->usr, $zit->config->pwd);
});

// Extend Zit with new functionality
Zit::extend('end', function($zit) {
    $zit->db->close();
    $zit->session->destroy();
});

// Finish
Zit::end();
```

> Which approach should you use? Whatever you prefer. If you aren't sure, you can use the *static way* unless you need to create your own instance that extends **Zit**

#### Note

[](#note)

> Whether you **bind()**, **stash()**, or **extend()** it. You can pop it out using:

```
Zit::pop('db');  // Formal
Zit::db();       // Via __callStatic()
Zit::db          // Via __callStatic() property sniffing

// If you had done $app = Zit::make()
$app->pop('db'); // Formal
$app->db();      // Via __call()
$app->db;        // Via __get()
```

### API

[](#api)

#### `pop($id, $args = array())`

[](#popid-args--array)

> **pop()** lets you pop a dependency out of the container

```
Zit::pop('db');
// See the note above on popping stuff out
```

#### `bind($id, callable $serviceGenerator)`

[](#bindid-callable-servicegenerator)

> **bind()** lets you register a service generator. Useful when you need to instantiate a service that depends on a config object for example. Services get generated *only once* on first call.

```
Zit::make()->bind('db', function($zit) {
   return new Db($zit->config->usr, $zit->config->pwd);
});
```

#### `stash($id, $service)`

[](#stashid-service)

> **stash()** lets you stash anything inside the container. You get out what you put in, which is useful if you need to stash a bunch of stuff that needs to be accessible throughout your whole application.

```
Zit::make()->stash('session', new Session())
```

#### `extend($id, $callback)`

[](#extendid-callback)

> **extend()** gives you the ability to add new functionality to the container

```
Zit::make()->extend('logout', function($zit) {
    $zit->session->logout();
});
```

---

### Contribute

[](#contribute)

> **Zit** wants to be friendly to *first time contributors*. Just follow the steps below and if you have questions along the way, please reach out.

1. Fork it!
2. Create your bugfix or feature branch
3. Commit and push your changes
4. Submit a pull request

### License

[](#license)

**Zit** is open source software licensed under the [MIT License](LICENSE.txt)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 96.6% 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 ~129 days

Recently: every ~206 days

Total

9

Last Release

3661d ago

Major Versions

v0.5.2 → v1.0.02016-06-16

PHP version history (2 changes)v0.1.0PHP &gt;=5.3.2

v1.0.0PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/93d52d70a5bafe64daf0512be1f3473bae56fa5bfb255258e30d6de3dcfcd170?d=identicon)[selvinortiz](/maintainers/selvinortiz)

---

Top Contributors

[![selvinortiz](https://avatars.githubusercontent.com/u/1922523?v=4)](https://github.com/selvinortiz "selvinortiz (28 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

dependencyinjectionzit

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k193.1M3.0k](/packages/composer-composer)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k309.5M3.0k](/packages/symfony-property-access)[php-di/invoker

Generic and extensible callable invoker

26762.3M66](/packages/php-di-invoker)[bamarni/composer-bin-plugin

No conflicts for your bin dependencies

52923.6M1.0k](/packages/bamarni-composer-bin-plugin)[contributte/di

Extra contrib to nette/di

465.9M18](/packages/contributte-di)[digital-creative/conditional-container

Provides an easy way to conditionally show and hide fields in your Nova resources.

114602.3k4](/packages/digital-creative-conditional-container)

PHPackages © 2026

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