kba-team / memory-container
PSR-11 container storing its values in memory and offering a singleton access.
v2.0.0
2023-10-19 15:00 UTC
Requires
- php: >=7.4
- psr/container: ^1.0
Requires (Dev)
- phpunit/phpunit: ^9.6
- squizlabs/php_codesniffer: ^3.7
Provides
README
PSR-11 container storing its values in memory and offering a singleton access.
Usage
A simple example:
<?php namespace vendor\product; class Greeter { public function __construct(\Closure $logic) { printf('%s%s', $logic('world'), PHP_EOL); } }
<?php use kbATeam\MemoryContainer\Container; use vendor\product\Greeter; Container::singleton()->add('hello', function ($what) { return sprintf('Hello %s!', $what); }); // ... $example = new Greeter(Container::singleton()->get('hello'));
Testing
Get composer, and install the dependencies.
composer install
Call phpunit to run the tests available.
vendor/bin/phpunit