コード例 #1
0
ファイル: services.php プロジェクト: fyibmsd/laralite
<?php

use NoahBuscher\Macaw\Macaw;
use System\Helper\Container\Container;
use Whoops\Run as Whoops;
use Whoops\Handler\PrettyPageHandler;
use Illuminate\Database\Capsule\Manager as Capsule;
use System\Helper\Config;
use System\Services\Redis;
$config = new Config(ROOT_PATH . '/config/config.yaml', Config::RESULT_AS_ARRAY);
$config->toArray();
$container = new Container();
// Route Service
$container->set('route', function () {
    return Macaw::class;
});
// Redis Service
$container->set('redis', function () use(&$config) {
    return new Redis($config['redis']);
});
// View Service
$container->set('view', function () use(&$config) {
    $loader = new Twig_Loader_Filesystem(ROOT_PATH . $config['path']['template']);
    $twig = new Twig_Environment($loader, ['cache' => ROOT_PATH . $config['path']['cache']]);
    return $twig;
});
// Debug Service
$container->set('debug', function () {
    // whoops 错误提醒
    $whoops = new Whoops();
    $whoops->pushHandler(new PrettyPageHandler());