PHPackages                             guide42/suda - 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. guide42/suda

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

guide42/suda
============

Registry of values and dependency injector

0.17.0(6y ago)3702ISCPHPPHP &gt;=7.2

Since Oct 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/guide42/suda)[ Packagist](https://packagist.org/packages/guide42/suda)[ RSS](/packages/guide42-suda/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (1)Versions (18)Used By (0)

SUDA
====

[](#suda)

Suda is a lightweight container for your services.

Quick Start
-----------

[](#quick-start)

Creating and configuring the registry is as simple as giving an associative array that map a class to a factory or a key to a parameter value.

```
$di = new suda\Registry([
    MovieFinder::class => function(callable $make) {
        return new MovieFinder;
    },
    MovieLister::class => function(callable $make, MovieFinder $finder) {
        return new MovieLister($finder);
    },
]);
```

All objects are created once, when first requested, using the factory, and the same instance will be returned at each lookup.

```
$finder0 = $di[MovieFinder::class];
$finder1 = $di[MovieFinder::class];

assert($finder0 === $finder1);
```

Factories
---------

[](#factories)

Any callable that accepts a make function as first argument is a factory, any other arguments are resolved as dependencies. It purpose is to create the object when the class or interface is requested.

Factories can be stacked and called in a middleware fashion. The given `make`function when called without arguments will:

- Calls the previous factory if stacked,
- Or tries to create the object of the concrete class key, resolving its dependencies.

```
$di[ConcreteHouse::class] = function(callable $make) {
    $house = $make(); // creates the object resolving dependencies
    return $house;
};
$di[ConcreteHouse::class] = function(callable $make) {
    $house = $make(); // calls the previous factory
    $house->build();
    return $house;
};
```

The `make` function also can be used to create any class with arguments:

```
$di[NumberValidatorInterface::class] = function(callable $make) {
    return $make(BCNumberValidator::class, ['min' => 5]);
};
```

API
---

[](#api)

```
$di = new Registry;                                    // creates empty registry
$di = new Registry(array $values);                     // ... with assoc-array containing values or factories
$di = new Registry(array $values, Registry $delegate); // ... with registry to delegate dependencies

$di[string $classOrInterface] = callable $factory;     // stores a factory for abstract
$di[string $key] = mixed $value;                       // stores a parameter

$di(callable $fn);                                     // call a function resolving it's parameters
$di(callable $fn, array $arguments);                   // ... with given arguments

$di->freeze();                                         // disallow to store values or factories
$di->freeze(string $key);                              // ... for this entry key
```

Badges
------

[](#badges)

[![Latest Stable Version](https://camo.githubusercontent.com/e4580a0bb00547145210b862e847f2d1c4272f147c28e45635ef450df0f81e83/68747470733a2f2f706f7365722e707567782e6f72672f677569646534322f737564612f762f737461626c652e737667)](https://packagist.org/packages/guide42/suda)[![Build Status](https://camo.githubusercontent.com/8d5f5f17f5ca00ed95b9c2a1acdb0776d76178e8126f980d5b757eca216d3620/68747470733a2f2f7472617669732d63692e6f72672f677569646534322f737564612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/guide42/suda)[![Coverage Status](https://camo.githubusercontent.com/f46937f2259a7d35ad2886ee25679f960dfad86c87ed6ed451663d64865292ff/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f677569646534322f737564612f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/guide42/suda)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

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

Recently: every ~269 days

Total

17

Last Release

2213d ago

PHP version history (4 changes)v0.1.0PHP &gt;=5.3

v0.7.0PHP &gt;=7.0

v0.9.0PHP ^7.1

v0.14.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/c439f8b528698cc845fd4ffac60724c0533f58a235155ce2e775870e83937fdf?d=identicon)[joksnet](/maintainers/joksnet)

![](https://avatars.githubusercontent.com/u/1421187?v=4)[guide42](/maintainers/guide42)[@guide42](https://github.com/guide42)

---

Top Contributors

[![jm42](https://avatars.githubusercontent.com/u/3297150?v=4)](https://github.com/jm42 "jm42 (175 commits)")

---

Tags

containerdependency-injectiondiregistrycontainerdependency-injectiondiregistry

### Embed Badge

![Health badge](/badges/guide42-suda/health.svg)

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

2.9k55.5M1.2k](/packages/php-di-php-di)[aura/di

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

356990.6k60](/packages/aura-di)[mrclay/props-dic

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

3512.7M3](/packages/mrclay-props-dic)[slince/di

A flexible dependency injection container

20272.1k6](/packages/slince-di)[capsule/di

A PSR-11 compliant autowiring dependency injection container.

2860.1k2](/packages/capsule-di)

PHPackages © 2026

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