コード例 #1
0
<?php

use Phalcon\Logger\Adapter\File as Logger;
//The session service is available by default, but we overwrite it
//because we want to use Redis to store our session
$di['session'] = function () use($config) {
    $session = new \Phalcon\Session\Adapter\Redis(array('uniqueId' => $config->session->unique_id, 'path' => $config->session->path, 'name' => $config->session->name));
    $session->start();
    return $session;
};
//The security session is available by default, but we overwrite it
//because we want to set it's options
$di['security'] = function () {
    $security = new \Phalcon\Security();
    $security->setWorkFactor(10);
    return $security;
};
//Connect to the Redis server
$di['redis'] = function () use($config) {
    $redis = new \Redis();
    $redis->connect($config->redis->host, $config->redis->port);
    return $redis;
};
//Overwrite for backwards compatibility
$di['url'] = function () use($config) {
    $url = new \Phalcon\Mvc\Url();
    return $url;
};
//Custom DI component to use for the Volt template engine
$di['voltService'] = function ($view, $di) use($config) {
    $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
コード例 #2
0
ファイル: Init.php プロジェクト: nguyenducduy/haraapp
 /**
  * Init session.
  *
  * @param DI     $di     Dependency Injection.
  * @param Config $config Config object.
  *
  * @return SessionAdapter
  */
 protected function _initSession($di, $config)
 {
     $session = new \Phalcon\Session\Adapter\Redis(['path' => "tcp://127.0.0.1:6379?weight=1", 'persistent' => false, 'lifetime' => 3600, 'prefix' => '_haraapp_']);
     $session->start();
     $di->setShared('session', $session);
     return $session;
 }