当前位置: 首页>>代码示例>>PHP>>正文


PHP Adapter\Files类代码示例

本文整理汇总了PHP中Phalcon\Session\Adapter\Files的典型用法代码示例。如果您正苦于以下问题:PHP Files类的具体用法?PHP Files怎么用?PHP Files使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Files类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Phalcon\Session\Adapter\Files constructor
  *
  * @param array $options
  */
 public function __construct($options = null)
 {
     if (isset($options['name'])) {
         ini_set('session.name', $options['name']);
     }
     if (isset($options['lifetime'])) {
         ini_set('session.gc_maxlifetime', $options['lifetime']);
     }
     if (isset($options['cookie_lifetime'])) {
         ini_set('session.cookie_lifetime', $options['cookie_lifetime']);
     }
     parent::__construct($options);
 }
开发者ID:tashik,项目名称:phalcon_core,代码行数:18,代码来源:Files.php

示例2: commonServices


//.........这里部分代码省略.........
     }
     // 默认缓存
     if ($config = config('cache')) {
         $di->set('cache', function () use($config) {
             $cache = null;
             $adapter = strtolower($config['adapter']);
             $options = $config[$adapter];
             $frontend = new Data(array('lifetime' => $config['lifetime']));
             switch ($adapter) {
                 case 'memcache':
                     $cache = new Memcache($frontend, $options);
                     break;
                 case 'redis':
                     if (empty($options['auth'])) {
                         unset($options['auth']);
                     }
                     $cache = new \Phalcon\Extend\Cache\Backend\Redis($frontend, $options);
                     break;
             }
             return $cache;
         }, true);
     }
     // Cookies
     if ($config = config('cookies')) {
         $di->set('cookies', function () use($config) {
             $cookies = new \Phalcon\Extend\Http\Response\Cookies($config);
             if (!config('crypt.authkey')) {
                 $cookies->useEncryption(false);
             }
             return $cookies;
         }, true);
     }
     // Session
     if ($config = config('session')) {
         $di->set('session', function () use($config) {
             if (!empty($config['options'])) {
                 foreach ($config['options'] as $name => $value) {
                     ini_set("session.{$name}", $value);
                 }
             }
             $adapter = strtolower($config['adapter']);
             $options = $config[$adapter];
             switch ($adapter) {
                 case 'memcache':
                     $session = new SessionMemcache($options);
                     break;
                 case 'redis':
                     $session = new \Phalcon\Extend\Session\Adapter\Redis($options);
                     break;
                 default:
                     $session = new SessionFiles();
                     break;
             }
             $session->start();
             return $session;
         }, true);
     }
     // Db
     if ($config = config('db')) {
         $di->set('db', function () use($config) {
             $mysql = new Mysql($config);
             if (debugMode()) {
                 $eventsManager = new Manager();
                 $logger = new File(APP_LOG . DS . 'Mysql' . LOGEXT);
                 $formatter = new Line(null, 'Y-m-d H:i:s');
                 $logger->setFormatter($formatter);
                 $eventsManager->attach('db', function ($event, $mysql) use($logger) {
                     if ($event->getType() == 'beforeQuery') {
                         $logger->log($mysql->getSQLStatement(), Logger::INFO);
                     }
                     if ($event->getType() == 'afterQuery') {
                     }
                 });
                 $mysql->setEventsManager($eventsManager);
             }
             return $mysql;
         }, true);
     }
     // DB 元信息
     if ($config = config('metadata')) {
         $di->set('modelsMetadata', function () use($config) {
             $modelsMetadata = null;
             $adapter = strtolower($config['adapter']);
             $options = $config[$adapter];
             switch ($adapter) {
                 case 'memcache':
                     $modelsMetadata = new MetaDataMemcache($options);
                     break;
                 case 'redis':
                     if (empty($options['auth'])) {
                         unset($options['auth']);
                     }
                     $modelsMetadata = new MetaDataRedis($options);
                     break;
             }
             return $modelsMetadata;
         }, true);
     }
     $this->application->setDI($di);
 }
开发者ID:smallmenu,项目名称:learning-phalcon,代码行数:101,代码来源:Bootstrap.php

示例3: _initSession

 /**
  * Init session.
  *
  * @param DI     $di     Dependency Injection.
  * @param Config $config Config object.
  *
  * @return SessionAdapter
  */
 protected function _initSession($di, $config)
 {
     $session = new PhSessionFiles();
     $session->start();
     $di->setShared('session', $session);
     return $session;
 }
开发者ID:nguyenducduy,项目名称:phblog,代码行数:15,代码来源:Init.php

示例4: setDi

function setDi()
{
    $di = new FactoryDefault();
    $di['router'] = function () use($di) {
        $router = new Router();
        $router->setDefaultModule('admin');
        return $router;
    };
    $di['url'] = function () {
        $url = new UrlResolver();
        $url->setBaseUri('/');
        return $url;
    };
    $di['session'] = function () {
        $session = new SessionAdapter();
        $session->start();
        return $session;
    };
    $loader = new Loader();
    $loader->registerNamespaces(array('Mall\\Mdu' => __DIR__ . '/../apps/mdu'));
    $sysConfig = (include __DIR__ . '/../config/sysconfig.php');
    $di['sysconfig'] = function () use($sysConfig) {
        return $sysConfig;
    };
    $loader->register();
    return $di;
}
开发者ID:nicklos17,项目名称:littlemall,代码行数:27,代码来源:index.php

示例5: registerServices

 /**
  * @param DI $di
  */
 public function registerServices($di)
 {
     //Registering a dispatcher
     $di->setShared('dispatcher', function () use($di) {
         $dispatcher = new Dispatcher();
         $dispatcher->setDefaultNamespace("Admin");
         $eventsManager = $di->getShared('eventsManager');
         $eventsManager->attach('dispatch', new AdminSecurity($di));
         $dispatcher->setEventsManager($eventsManager);
         return $dispatcher;
     });
     $auto_admin = new \AutoAdmin\Module();
     $auto_admin->registerServices($di);
     $di->setShared('admin_views_dir', function () {
         return ADMINROOT . '/views/';
     });
     $di->setShared('session', function () {
         $session = new Session();
         $session->start();
         return $session;
     });
     $di->setShared('config', function () use($di) {
         $configFront = (require COREROOT . '/app/config/config.php');
         $configBack = (require ADMINROOT . '/config/config.php');
         $configFront->merge($configBack);
         return $configFront;
     });
 }
开发者ID:moaljazaery,项目名称:phalcon-module-admin,代码行数:31,代码来源:module.php

示例6: initSession

 /**
  * Initializes the session
  *
  * @param array $options
  */
 protected function initSession($options = array())
 {
     $this->di['session'] = function () {
         $session = new PhSession();
         $session->start();
         return $session;
     };
 }
开发者ID:rajeshmsaaryan01,项目名称:website,代码行数:13,代码来源:bootstrap.php

示例7: register

 /**
  * Registers the session component in the DI container.
  * 
  * @return void
  */
 public function register()
 {
     $this->di->setShared('session', function () {
         $session = new SessionAdapter();
         if (!$session->isStarted()) {
             $session->start();
         }
         return $session;
     });
 }
开发者ID:halfbakedsneed,项目名称:phalcore,代码行数:15,代码来源:Session.php

示例8: registerServices

 /**
  * Register services used by the backend application
  *
  * @param $di
  */
 public function registerServices($di)
 {
     $config = $this->config();
     /**
      * register the dispatcher
      */
     $di->set('dispatcher', function () {
         $dispatcher = new Dispatcher();
         /*$eventManager = new Manager();
                     $eventManager->attach('dispatch', new \Acl('backend'));
         
                     $dispatcher->setEventsManager($eventManager);*/
         $dispatcher->setDefaultNamespace('app\\backend\\controllers');
         return $dispatcher;
     });
     /**
      * The URL component is used to generate all kind of urls in the application
      */
     $di->set('url', function () use($config) {
         $url = new UrlResolver();
         $url->setBaseUri($config->application->baseUri);
         return $url;
     }, true);
     $di->setShared('view', function () use($config) {
         $view = new View();
         $view->setViewsDir($config->application->viewsDir);
         $view->registerEngines(['.volt' => function ($view, $di) use($config) {
             $volt = new VoltEngine($view, $di);
             $volt->setOptions(['compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '_']);
             return $volt;
         }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php']);
         return $view;
     });
     /**
      * Database connection is created based in the parameters defined in the configuration file
      */
     $di->set('db', function () use($config) {
         return new MysqlAdapter($config->database->toArray());
     });
     /**
      * If the configuration specify the use of metadata adapter use it or use memory otherwise
      */
     $di->set('modelsMetadata', function () {
         return new MetaDataAdapter();
     });
     /**
      * Start the session the first time some component request the session service
      */
     $di->setShared('session', function () {
         $session = new SessionAdapter();
         $session->start();
         return $session;
     });
 }
开发者ID:adrianeavaz,项目名称:manager.io,代码行数:59,代码来源:Module.php

示例9: onBoot

 public function onBoot()
 {
     // TODO: Implement onBoot() method.
     $this->getDI()->setShared('session', function () {
         $session = new Session();
         if (!$session->isStarted()) {
             $session->start();
         }
         return $session;
     });
 }
开发者ID:dotronglong,项目名称:phalcon-engine,代码行数:11,代码来源:ServiceRegister.php

示例10: connect

 /**
  * @inheritdoc
  */
 public function connect(array $config)
 {
     $session = new SessionAdapter();
     $id = di('crypt')->encrypt($config['app']['key']);
     $name = $config['session']['cookie'];
     //$session->setId($id);
     session_name($name);
     $session->setOptions(['uniqueId' => $id]);
     if (!$session->isStarted()) {
         $session->start();
     }
     return $session;
 }
开发者ID:broklyngagah,项目名称:orbit,代码行数:16,代码来源:FilesConnector.php

示例11: __construct

 public function __construct($options = null)
 {
     parent::__construct($options);
     $sessionPath = $options['save_path'];
     is_dir($sessionPath) or mkdir($sessionPath, 0755, true);
     session_save_path($sessionPath);
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:7,代码来源:Native.php

示例12: destroy

 /**
  * Destroys current session and removes session cookie
  * @return bool
  */
 public function destroy()
 {
     // Remove session cookie
     $options = $this->getCookieOptions();
     if (!setcookie($options['name'], '', -1)) {
         return false;
     }
     // Clean session data
     return parent::destroy();
 }
开发者ID:netassist-ua,项目名称:netgraphz2-gpl,代码行数:14,代码来源:SessionAdapter.php

示例13: __construct

 /**
  * {@inheritdoc}
  */
 public function __construct($options)
 {
     parent::__construct($options);
     if (!is_cli()) {
         if (isset($options['session_storage']) === false) {
             $options['session_storage'] = url_trimmer(config()->path->storage . '/session');
         }
         session_save_path($options['session_storage']);
         session_set_cookie_params($options['lifetime'], $options['path'], $options['domain'], $options['secure'], $options['httponly']);
     }
 }
开发者ID:ps-clarity,项目名称:support,代码行数:14,代码来源:Files.php

示例14: registerServices

 /**
  *
  * @param \Phalcon\DI $di
  */
 public function registerServices($di)
 {
     Admin::instance();
     require __DIR__ . '/../../../../phad/phad.php';
     $di['phadConfig'] = function () {
         $config = (require __DIR__ . '/../../../../phad-config.php');
         return new Config($config);
     };
     $di['view'] = function () {
         $view = new ViewEngine();
         $view->setViewsDir(__DIR__ . '/Views/');
         $view->setLayoutsDir('Layouts/');
         $view->setPartialsDir('Partials/');
         return $view;
     };
     $di['viewSimple'] = function () {
         $view = new Simple();
         $view->setViewsDir(__DIR__ . '/Views/');
         return $view;
     };
     $di['flashSession'] = function () {
         $flashClasses = ['error' => 'alert alert-danger', 'success' => 'alert alert-success', 'notice' => 'alert alert-info', 'warning' => 'alert alert-warning'];
         return new FlashSession($flashClasses);
     };
     $di['session'] = function () {
         $session = new Session();
         $session->start();
         return $session;
     };
     $di['phadAuth'] = function () {
         return new Auth();
     };
     $di['assets'] = function () use($di) {
         $options = ['sourceBasePath' => __DIR__ . '/Assets/', 'targetBasePath' => __DIR__ . '/../../../../public/backend-assets/'];
         $assets = new AssetsManager($options);
         $assets->collection('backend_css')->setTargetPath('final.css')->setTargetUri('backend-assets/final.css')->addCss('bootstrap/css/bootstrap.min.css')->addCss('css/styles.css')->join(true)->addFilter(new AssetsNullFilter());
         $assets->collection('backend_js')->setTargetPath('final.js')->setTargetUri('backend-assets/final.js')->addJs('bootstrap/js/bootstrap.min.js')->addJs('js/custom.js')->join(true)->addFilter(new AssetsNullFilter());
         return $assets;
     };
 }
开发者ID:argentum88,项目名称:phad,代码行数:44,代码来源:Module.php

示例15: unset

    $adapter = $dbConfig['adapter'];
    unset($dbConfig['adapter']);
    $class = 'Phalcon\\Db\\Adapter\\Pdo\\' . $adapter;
    return new $class($dbConfig);
});
/**
 * If the configuration specify the use of metadata adapter use it or use memory otherwise
 */
$di->setShared('modelsMetadata', function () {
    return new MetaDataAdapter();
});
/**
 * Start the session the first time some component request the session service
 */
$di->setShared('session', function () {
    $session = new SessionAdapter();
    $session->start();
    (new TranslateEngine())->initialize($session);
    return $session;
});
$di->set('dispatcher', function () {
    // Create an event manager
    $eventsManager = new EventsManager();
    // Attach a listener for type "dispatch"
    $eventsManager->attach("dispatch", function ($event, $dispatcher) {
        // ...
    });
    $dispatcher = new MvcDispatcher();
    // Bind the eventsManager to the view component
    $dispatcher->setEventsManager($eventsManager);
    return $dispatcher;
开发者ID:jcheron,项目名称:phalcon-jquery-website,代码行数:31,代码来源:services.php


注:本文中的Phalcon\Session\Adapter\Files类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。