bapcat/services

0.3 2019-01-03 21:26 UTC

This package is auto-updated.

Last update: 2024-11-15 06:22:16 UTC


README

Build Status Coverage Status License

Services

This package provides a controlled boot environment for cross-package dependencies.

Installation

Composer

Composer is the recommended method of installation for BapCat packages.

$ composer require bapcat/services

GitHub

BapCat packages may be downloaded from GitHub.

Features

Registration

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