codesaur / container
Хөнгөн, хурдан, PSR-11 стандартад нийцсэн dependency injection container
Installs: 14
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/codesaur/container
Requires
- php: ^8.2.1
- psr/container: ^2.0.2
Requires (Dev)
- phpunit/phpunit: ^10.0
README
Агуулга / Table of Contents
- Монгол | 2. English | 3. Getting Started
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-тэй нийцтэй
- ✔ Ямар ч гадны нэмэлт хамааралгүй
Дэлгэрэнгүй мэдээлэл
- 📖 Бүрэн танилцуулга - Суурилуулалт, хэрэглээ, жишээнүүд
- 📚 API тайлбар - Бүх метод, exception-үүдийн тайлбар
- 🔍 Код шалгалт - Код шалгалтын тайлан
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
- ✔ 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
- 📖 Full Documentation - Installation, usage, examples
- 📚 API Reference - Complete API documentation
- 🔍 Code Review - Code review report
3. Getting Started
Requirements
- PHP 8.2.1+
- Composer
Installation
Composer ашиглан суулгана / Install via Composer:
composer require codesaur/container
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
Тест ажиллуулах / Run tests:
# Бүх тестүүдийг ажиллуулах / Run all tests composer test # Coverage-тэй тест ажиллуулах / Run tests with coverage composer test:coverage
Changelog
- 📝 CHANGELOG.md - Full version history
Contributing & Security
License
This project is licensed under the MIT License.
Author
Narankhuu
📧 codesaur@gmail.com
🌐 https://github.com/codesaur
🏗️ codesaur Ecosystem: https://codesaur.net