Skip to content
/ sleeve Public

A trivial extension of Pimple Container with PSR-11 compatibility and convenience methods.

License

Notifications You must be signed in to change notification settings

dakujem/sleeve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sleeve

PHP from Packagist Coverage Status Nature Friendly

A lightweight PSR-11 service container.
A trivial extension of Symfony Pimple container.

💿 composer require dakujem/sleeve

Sleeve...

  • is dead simple
  • is PSR-11 compatible
  • extends Pimple (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 and other micro frameworks and stacks

Usage

Added on top of Pimple:

  • methods get, set, has, unset
  • magic accessors __get, __set, __isset, __unset

Examples:

$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. It's quite short, in fact.

Testing

composer test

Tested for PHP versions 7.1 onwards.

About

A trivial extension of Pimple Container with PSR-11 compatibility and convenience methods.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages