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: 2 months 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 (almost 6 years ago)
- Default Branch: trunk
- Last Pushed: 2025-02-14T10:05:22.000Z (4 months ago)
- Last Synced: 2025-03-17T17:43:56.814Z (3 months ago)
- Topics: dependency-injection-container, pimple, psr-11
- Language: PHP
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# Sleeve

[](https://coveralls.io/github/dakujem/sleeve?branch=trunk)
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.