init() публичный статический Метод

Initialize the Gatekeeper instance, set up environment file and PDO connection
public static init ( string $envPath = null, array $config = [], DataSource $datasource = null, $logger = null )
$envPath string Environment file path (defaults to CWD)
$config array Configuration settings [optional]
$datasource DataSource Custom datasource provider
Пример #1
0
 *
 * These definitions will be available in the app's controllers etc.
 */
use function DI\object;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use Monolog\ErrorHandler;
use Monolog\Handler\BrowserConsoleHandler;
use Monolog\Handler\StreamHandler;
use Psecio\Gatekeeper\Gatekeeper;
use SitePoint\Rauth;
use Tamtamchik\SimpleFlash\Flash;
use Tamtamchik\SimpleFlash\TemplateFactory;
use Tamtamchik\SimpleFlash\Templates;
use Psr\Log\LoggerInterface as Logger;
Gatekeeper::init(__DIR__ . '/../../');
Gatekeeper::disableThrottle();
$user = null;
if (isset($_SESSION['user'])) {
    $user = Gatekeeper::findUserByUsername($_SESSION['user']);
    if (!$user) {
        session_destroy();
        unset($_SESSION['user']);
        header('Location: /');
        die;
    }
}
if (getenv('INTL') == 'true') {
    $language = getenv('INTL_LANG');
    putenv("LANGUAGE=" . $language);
    setlocale(LC_ALL, $language);
Пример #2
0
 public function __construct()
 {
     $config = array('type' => 'mysql', 'username' => 'gk-user', 'password' => 'password', 'name' => 'gatekeeper', 'host' => 'localhost', 'throttle' => false);
     Gatekeeper::init(null, $config);
 }
Пример #3
0
 /**
  * Init the object and use the Laravel DB config to
  *     set up the PDO object
  */
 public function __construct()
 {
     $config = \Config::get('database.connections.gatekeeper');
     Gatekeeper::init(null, array('type' => $config['driver'], 'username' => $config['username'], 'password' => $config['password'], 'host' => $config['host'], 'name' => 'gatekeeper'));
 }
Пример #4
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;
 /**
  * Register (start) the service provider
  * 	Sets up the Gatekeeper instance with init() call
  */
 public function register()
 {
     $config = array('username' => env('GATEKEEPER_USER'), 'password' => env('GATEKEEPER_PASS'), 'host' => env('GATEKEEPER_HOST'), 'name' => env('GATEKEEPER_DATABASE'));
     Gatekeeper::init(null, $config);
 }