PHP Classes

File: src/dependencies.php

Recommend this page to a friend!
  Classes of Scott Arciszewski  >  Chronicle  >  src/dependencies.php  >  Download  
File: src/dependencies.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Chronicle
Append arbitrary data to a storage container
Author: By
Last change:
Date: 3 years ago
Size: 1,037 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);

use
Slim\Container;
// DIC configuration

if (!isset($app)) {
    throw new
Error('Variable $app is not defined');
}
if (!(
$app instanceof \Slim\App)) {
    throw new
Error('Variable $app is not an App');
}

/** @var Container $container */
$container = $app->getContainer();

// view renderer
$container['renderer'] = function (Container $c): \Slim\Views\PhpRenderer {
   
$settings = $c->get('settings')['renderer'];
    return new
Slim\Views\PhpRenderer($settings['template_path']);
};

// monolog
$container['logger'] = function (Container $c): \Monolog\Logger {
   
$settings = $c->get('settings')['logger'];
   
$logger = new Monolog\Logger($settings['name']);
   
$logger->pushProcessor(new Monolog\Processor\UidProcessor());
   
$logger->pushHandler(new Monolog\Handler\StreamHandler($settings['path'], $settings['level']));
    return
$logger;
};

// easydb
$container['database'] = function (Container $c): \ParagonIE\EasyDB\EasyDB {
    return \
ParagonIE\Chronicle\Chronicle::getDatabase();
};

For more information send a message to info at phpclasses dot org.