This package provides a controlled boot environment for cross-package dependencies.
Composer is the recommended method of installation for BapCat packages.
$ composer require bapcat/services
BapCat packages may be downloaded from GitHub.
The main use for Services is to register IoC bindings.
<?php namespace BapCat\CoolLogger;
use BapCat\CoolLogger\Logger;
use BapCat\Interfaces\Ioc\Ioc;
class LoggingServiceProvider implements ServiceProvider {
private $ioc;
public function __construct(Ioc $ioc) {
$this->ioc = $ioc;
}
public function register() {
// Make Logger a singleton
$this->ioc->singleton(Logger::class, Logger::class);
// Bind the bap.log alias to the Logger singleton
$this->ioc->bind('bap.log', Logger::class);
}
}