jaeger-app / bootstrap
A pre-configured dependency injection container and start-up initialization object.
Requires
- php: >=5.4.0
- jaeger-app/console: ^0.1
- jaeger-app/db: ^0.1
- jaeger-app/di: ^0.1
- jaeger-app/email: ^0.1
- jaeger-app/encrypt: ^0.1
- jaeger-app/errors: ^0.1
- jaeger-app/exceptions: ^0.1
- jaeger-app/files: ^0.1
- jaeger-app/language: ^0.1
- jaeger-app/license: ^0.1
- jaeger-app/regex: ^0.1
- jaeger-app/settings: ^0.1
- jaeger-app/shell: ^0.1
- jaeger-app/validate: ^0.1
- jaeger-app/view: ^0.1
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2023-11-18 01:40:47 UTC
README
A pre-configured dependency injection container and start-up initialization object. Jaeger Bootstrap will prepare the most common Jaeger objects and make them ready for use as well as function as a stand alone dependency injection container utilizing Pimple\Container.
Installation
Add jaeger-app/bootstrap
as a requirement to your composer.json
:
$ composer require jaeger-app/bootstrap
Simple Example
use \JaegerApp\Bootstrap; $bootstrap = new Bootstrap(); //get all the services $services = $bootstrap->getServices(); //get a specific service $db = $services['db']; //or ger specific service directly $db = $bootstrap->getService('db');
Configured Services
Jaeger\Bootstrap
sets up quite a few Jaeger objects and makes them ready for use.
use \JaegerApp\Bootstrap; $bootstrap = new Bootstrap(); $db = $bootstrap->getService('db'); $email = $bootstrap->getService('email'); $encrypt = $bootstrap->getService('encrypt'); $lang = $bootstrap->getService('lang'); $validate = $bootstrap->getService('validate'); $files = $bootstrap->getService('files'); $view = $bootstrap->getService('view'); $shell = $bootstrap->getService('shell'); $console = $bootstrap->getService('console');
Adding Services
Ideally, like all Jaeger classes, you should extend Jaeger\Bootstrap
and initialize the parent services before adding your own like the below:
use \JaegerApp\Bootstrap; class MyBootstrap extends Bootstrap { public function getServices() { $this->container = parent::getServices(); //init existing services //add new service $this->container['my_service'] = function ($c) { $settings = new NewService; return $settings; }; return $this->container; } }
You can also add new Services at run time by using the setService($name, \Closure $function)
method.
use \JaegerApp\Bootstrap; $bootstrap = new Bootstrap(); $callable = function() { return 'foo to the who'; }; $bootstrap->setService('test_service', $callable);