mlebkowski / silex-private-scope
Private scope handling for Silex container
0.1
2015-02-27 13:52 UTC
Requires
- silex/silex: ~2.0@dev
Requires (Dev)
- phpunit/phpunit: ~4.5
This package is auto-updated.
Last update: 2024-11-23 19:31:57 UTC
README
Create an instance of ScopedApplication
to hide your services by default:
$app = new Nassau\Silex\ScopedApplication([ 'version' => 1.0, ]); $app['private-service'] = function () { }; $app['version']; // 1.0; services are registered as public if passed to constructor $app['private-service']; // throws \Nassau\Silex\PrivateScopeViolationException
Create a public service by using publish()
method. Private services will be available from inside the closure:
$app = new Nassau\Silex\ScopedApplication; $app['public-service'] = $app->publish(function (Silex\Application $app) { return $app['private-service']; }); $app['private-service'] = function () { return "private" } $app['public-service']; // "private";