Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.
/ bootstrap Public archive

A pre-configured dependency injection container and start-up initialization object.

License

Notifications You must be signed in to change notification settings

jaeger-app/bootstrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jaeger Bootstrap Object

Build Status Scrutinizer Code Quality Author GitHub license

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);

About

A pre-configured dependency injection container and start-up initialization object.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages