Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dakujem/sleeve
A trivial extension of Pimple Container with PSR-11 compatibility and convenience methods.
https://github.com/dakujem/sleeve
dependency-injection-container pimple psr-11
Last synced: about 1 month ago
JSON representation
A trivial extension of Pimple Container with PSR-11 compatibility and convenience methods.
- Host: GitHub
- URL: https://github.com/dakujem/sleeve
- Owner: dakujem
- License: unlicense
- Created: 2019-07-04T20:36:56.000Z (over 5 years ago)
- Default Branch: trunk
- Last Pushed: 2023-11-29T08:38:32.000Z (about 1 year ago)
- Last Synced: 2024-11-16T18:07:19.602Z (about 2 months ago)
- Topics: dependency-injection-container, pimple, psr-11
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# Sleeve
![PHP from Packagist](https://img.shields.io/packagist/php-v/dakujem/sleeve)
[![Coverage Status](https://coveralls.io/repos/github/dakujem/sleeve/badge.svg?branch=trunk)](https://coveralls.io/github/dakujem/sleeve?branch=trunk)
![Nature Friendly](https://img.shields.io/badge/nature%20%F0%9F%8C%B3-friendly%20%F0%9F%92%9A-green)A lightweight PSR-11 service container.\
A trivial extension of [Symfony Pimple container](https://pimple.symfony.com).> 💿 `composer require dakujem/sleeve`
Sleeve...
- is dead simple
- is PSR-11 compatible
- extends [Pimple](https://github.com/silexphp/Pimple) ([pimple/pimple](https://packagist.org/packages/pimple/pimple)), a simple Dependency Injection Container by Symfony
- only adds a couple of convenience methods (accessors) on top of the original
- works well with [Slim v4](https://github.com/slimphp/Slim)
and other micro frameworks and stacks## Usage
Added on top of Pimple:
- methods `get`, `set`, `has`, `unset`
- magic accessors `__get`, `__set`, `__isset`, `__unset`Examples:
```php
$dic = new Dakujem\Sleeve;// the following are equivalent
$service = $dic->get('service'); // getter
$service = $dic['service']; // array accessor
$service = $dic->service; // magic accessor// it works for setting services as well
$factory = function(Container $dic) {
return new Acme\MyService($dic->get('dependency'));
};
$dic->set('service', $factory); // setter
$dic['service'] = $factory; // array accessor
$dic->service = $factory; // magic accessor
```Sleeve supports (through Pimple):
- singleton services (global)
- factory services (factories)
- parameters (with protection too)
- extensions (service providers)📖 For full documentation, read the [Pimple container usage documentation](https://github.com/silexphp/Pimple). It's quite short, in fact.
## Testing
```
composer test
```Tested for PHP versions 7.1 onwards.