Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arikaim/container
Dependency Injection Container
https://github.com/arikaim/container
arikaim arikaim-cms cms container dependency-injection dependency-injection-container
Last synced: 6 days ago
JSON representation
Dependency Injection Container
- Host: GitHub
- URL: https://github.com/arikaim/container
- Owner: arikaim
- License: mit
- Created: 2017-12-11T13:09:00.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-09T11:52:39.000Z (about 1 year ago)
- Last Synced: 2024-12-09T22:48:53.675Z (about 1 month ago)
- Topics: arikaim, arikaim-cms, cms, container, dependency-injection, dependency-injection-container
- Language: PHP
- Size: 38.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
## Arikaim Container
![version: 1.0.0](https://img.shields.io/github/release/arikaim/container.svg)
![license: MIT](https://img.shields.io/badge/License-MIT-blue.svg)Mini Dependency Injection Container
PSR-11 compatibility
#### Installation
```sh
composer require arikaim/container
```#### Usage
```php
use Arikaim\Container\Container;
$container = new Container();
```
**Add service to container**
```php
$container['service'] = function() {
echo "Service example";
};$container->add('service_add',function() {
echo "Service add example";
});$container->add('date',function () {
return new \DateTime();
});$date = $container['date'];
echo $date->format('Y-m-d');```
**Add parameters**```php
$container['config'] = "Config value";
```
**Replace service**
```php
$container->replace('service',function() {
echo "Replace Service";
});```
**Psr-11** compatibility implement the PSR-11 ContainerInterface
```php
$servcie = $container->get('service');if ($container->has('service')) {
\\ Service exists
}```
#### License
MIT License