Psecio\Gatekeeper\Gatekeeper::getConfig PHP 메소드

getConfig() 공개 정적인 메소드

Get the current configuration information If an index is given, it tries to find it. If found, returns just that value. If not, returns null. Otherwise returns all config values
public static getConfig ( string $index = null ) : mixed
$index string Index to locate [optional]
리턴 mixed Single value if index found, otherwise array of all
    public static function getConfig($index = null)
    {
        if ($index !== null) {
            return isset(self::$config[$index]) ? self::$config[$index] : null;
        } else {
            return self::$config;
        }
    }

Usage Example

예제 #1
0
<?php

use Pimple\Container;
require_once '../vendor/autoload.php';
// Custom autoloader
spl_autoload_register(function ($class) {
    $path = __DIR__ . '/lib/' . str_replace('\\', '/', $class) . '.php';
    if (is_file($path)) {
        require_once $path;
    }
});
session_start();
$app = new \Slim\Slim();
\Psecio\Gatekeeper\Gatekeeper::init('../');
$config = \Psecio\Gatekeeper\Gatekeeper::getConfig();
$app->config(array('view' => new \GatekeeperUI\View\TemplateView(), 'templates.path' => '../templates', 'debug' => true));
$app->contentType('text/html; charset=utf-8');
define('ACCEPT_JSON', strstr($app->request->headers->get('Accept'), 'application/json') !== false);
$view = $app->view();
$view->parserExtensions = array(new \Slim\Views\TwigExtension());
$view->parserOptions = array('debug' => true);
$di = new Container();
$di['db'] = function () {
    $dsn = 'mysql:host=' . $config['host'] . ';dbname=' . $config['name'] . ';charset=UTF8';
    return new \PDO($dsn, $config['username'], $config['password']);
};
$app->di = $di;