PSR-11 container decorator caching resolved instances. This package is compliant with PSR-1, PSR-2, PSR-4 and PSR-11. If you notice compliance oversights, please send a patch via pull request.
Via Composer
$ composer require yucadoo/singleton-container
/** @var Psr\Container\ContainerInterface */
$resolvingContainer;
$singletonContainer = new YucaDoo\SingletonContainer\SingletonContainer($resolvingContainer);
// Resolves the instance using the injected container
$instance = $singletonContainer->get('Interface');
// Returns same instance
$sameInstance = $singletonContainer->get('Interface');
// Confirms that intance is cached
$singletonContainer->isCached('Interface');
// Clear cached instance
$singletonContainer->clear('Interface');
// Clear all cached instances
$singletonContainer->clearAll();
Please see CHANGELOG for more information on what has changed recently.
$ composer test
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.