PHP code example of bapcat / services
1. Go to this page and download the library: Download bapcat/services library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bapcat / services example snippets
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);
}
}