Esempio n. 1
0
 private function mvcDi()
 {
     $c = $this->config();
     $di = new FactoryDefault();
     //TODO:url
     //Register a session container
     $di->setShared('session', function () use($c) {
         $session = new SessionAdapter();
         session_set_cookie_params(0, '/', $c->hostname);
         $session->start();
         return $session;
     });
     //Register rendering mechanism
     $di->setShared('view', function () {
         $view = new View();
         $view->registerEngines(['.phtml' => 'PhalconZ\\Lib\\PhpViewEngine']);
         return $view;
     });
     $di->setShared('config', $this->config());
     $di->set('router', $this->mvcRouter());
     $this->database($di);
     return $di;
 }
Esempio n. 2
0
 * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
 */
$di = new FactoryDefault();
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di['url'] = function () {
    $url = new UrlResolver();
    $url->setBaseUri('/');
    return $url;
};
/**
 * Start the session the first time some component request the session service
 */
$di->set('session', function () {
    $memcache = new SessionAdapter(array('host' => 'localhost', 'port' => 11211, 'lifetime' => 172800, 'prefix' => 'thienmenh', 'persistent' => false));
    $memcache->start();
    return $memcache;
});
//Set Cache
$di->set('cache', function () {
    $frontCache = new Phalcon\Cache\Frontend\Data(array("lifetime" => 3600));
    $cache = new Phalcon\Cache\Backend\Memcache($frontCache, array("servers" => array(array("host" => "localhost", "port" => "11211", "weight" => "1"))));
    return $cache;
});
//Set Cache
$di->set('file_cache', function () {
    $frontCache = new Phalcon\Cache\Frontend\Data(array("lifetime" => 3600));
    $backendOptions = array('cacheDir' => '../app/frontend/cache/data/');
    $cache = new Phalcon\Cache\Backend\File($frontCache, $backendOptions);
    return $cache;
Esempio n. 3
0
 public function getLifetime()
 {
     return parent::getLifetime();
 }