PHPackages                             codesaur/container - 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. codesaur/container

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

codesaur/container
==================

Хөнгөн, хурдан, PSR-11 стандартад нийцсэн dependency injection container

v3.2.0(2d ago)1715↑164.7%1MITPHPPHP ^8.2.1CI passing

Since Sep 10Pushed 2d ago1 watchersCompare

[ Source](https://github.com/codesaur-php/Container)[ Packagist](https://packagist.org/packages/codesaur/container)[ Docs](https://github.com/codesaur-php)[ RSS](/packages/codesaur-container/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (6)Versions (20)Used By (1)

codesaur/container
==================

[](#codesaurcontainer)

[![CI](https://github.com/codesaur-php/Container/workflows/CI/badge.svg)](https://github.com/codesaur-php/Container/workflows/CI/badge.svg)[![PHP Version](https://camo.githubusercontent.com/1015683ef28e870620edc19b6e22b456c0dc170c260fa4645905e93438f607a6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322e312d3737374242342e7376673f6c6f676f3d706870)](https://www.php.net/)[![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)

Агуулга / Table of Contents
---------------------------

[](#агуулга--table-of-contents)

1. [Монгол](#1-%D0%BC%D0%BE%D0%BD%D0%B3%D0%BE%D0%BB-%D1%82%D0%B0%D0%B9%D0%BB%D0%B1%D0%B0%D1%80) | 2. [English](#2-english-description) | 3. [Getting Started](#3-getting-started)

---

1. Монгол тайлбар
-----------------

[](#1-монгол-тайлбар)

Хөнгөн, хурдан, PSR-11 стандартад нийцсэн **dependency injection container**.
Энэ багц нь **codesaur ecosystem**-ийн үндсэн бүрэлдэхүүн боловч ямар ч PHP төслөөс бие даан ашиглах боломжтой.

### Онцлогууд

[](#онцлогууд)

- PSR-11 `ContainerInterface`-ийг хэрэгжүүлдэг
- Lazy Loading - Сервисүүд зөвхөн шаардлагатай үед үүсгэгдэнэ
- Auto-wiring - Dependency-үүдийг автоматаар resolve хийх
- Interface Binding - Interface-үүдийг implementation-уудтай холбох
- Service Aliases - Нэг сервисийг олон нэрээр авах
- Reflection ашиглан автоматаар instance үүсгэнэ
- Closure / callable дэмжлэг
- Framework-agnostic - Бүх PHP framework-тэй нийцтэй
- Ямар ч гадны нэмэлт хамааралгүй

### Дэлгэрэнгүй мэдээлэл

[](#дэлгэрэнгүй-мэдээлэл)

- [Бүрэн танилцуулга](docs/mn/README.md) - Суурилуулалт, хэрэглээ, жишээнүүд
- [API тайлбар](docs/mn/api.md) - Бүх метод, exception-үүдийн тайлбар
- [Код шалгалт](docs/mn/code-review.md) - Код шалгалтын тайлан

---

2. English description
----------------------

[](#2-english-description)

Lightweight, fast, PSR-11 compliant **dependency injection container**.
This package is a component of the **codesaur ecosystem** but can be used independently in any PHP project.

### Features

[](#features)

- Implements PSR-11 `ContainerInterface`
- Lazy Loading - Services are created only when needed
- Auto-wiring - Automatic dependency resolution
- Interface Binding - Bind interfaces to implementations
- Service Aliases - Access one service by multiple names
- Automatically creates instances from classes using Reflection
- Closure / callable support
- Framework-agnostic - Compatible with all PHP frameworks
- No external dependencies required

### Documentation

[](#documentation)

- [Full Documentation](docs/en/README.md) - Installation, usage, examples
- [API Reference](docs/en/api.md) - Complete API documentation
- [Code Review](docs/en/code-review.md) - Code review report

---

3. Getting Started
------------------

[](#3-getting-started)

### Requirements

[](#requirements)

- PHP **8.2.1+**
- Composer

### Installation

[](#installation)

Composer ашиглан суулгана / Install via Composer:

```
composer require codesaur/container
```

### Quick Example

[](#quick-example)

```
use codesaur\Container\Container;

// Контейнер үүсгэх / Create container
$container = new Container();

// Класс бүртгэх / Register class
$container->set(MyService::class);

// Параметртэй класс бүртгэх / Register class with parameters
$container->set(Printer::class, ['Hello, World!']);

// Сервис авах / Get service
$service = $container->get(MyService::class);
$printer = $container->get(Printer::class);

// Сервис байгаа эсэхийг шалгах / Check if service exists
if ($container->has(MyService::class)) {
    // ...
}

// Сервис ашиглах / Use service
$printer->print(); // Output: Hello, World!
```

### Running Tests

[](#running-tests)

Тест ажиллуулах / Run tests:

```
# Бүх тестүүдийг ажиллуулах / Run all tests
composer test

# Coverage-тэй тест ажиллуулах / Run tests with coverage
composer test:coverage
```

---

Changelog
---------

[](#changelog)

- [CHANGELOG.md](CHANGELOG.md) - Full version history

Contributing &amp; Security
---------------------------

[](#contributing--security)

- [Contributing Guide](.github/CONTRIBUTING.md)
- [Security Policy](.github/SECURITY.md)

License
-------

[](#license)

This project is licensed under the MIT License.

Author
------

[](#author)

**Narankhuu**

**codesaur Ecosystem:**

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance99

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity72

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

Recently: every ~44 days

Total

19

Last Release

2d ago

Major Versions

v1.2.1 → v2.0.02025-12-15

v2.1.0 → v3.0.02025-12-18

PHP version history (3 changes)v1.0PHP &gt;=7.2.0

v1.0.3PHP &gt;=8.2.1

v3.0.0PHP ^8.2.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4127594?v=4)[Наранхүү Н](/maintainers/codesaur)[@codesaur](https://github.com/codesaur)

---

Top Contributors

[![codesaur](https://avatars.githubusercontent.com/u/4127594?v=4)](https://github.com/codesaur "codesaur (59 commits)")

---

Tags

containerPSR-11dependency-injectioncodesaurmongolmongolianarankhuucodenкодзаврнаранхүүкоден

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codesaur-container/health.svg)

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

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

A flexible dependency injection container

20272.1k6](/packages/slince-di)[infocyph/intermix

A lightweight PHP DI container, invoker, serializer, and utility toolkit.

137.7k2](/packages/infocyph-intermix)[phpwatch/simple-container

A fast and minimal PSR-11 compatible Dependency Injection Container with array-syntax and without auto-wiring

1811.7k2](/packages/phpwatch-simple-container)

PHPackages © 2026

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