本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
});
}
示例6: initSession
/**
* Initializes the session
*
* @param array $options
*/
protected function initSession($options = array())
{
$this->di['session'] = function () {
$session = new PhSession();
$session->start();
return $session;
};
}
示例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;
});
}
示例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;
});
}
示例9: onBoot
public function onBoot()
{
// TODO: Implement onBoot() method.
$this->getDI()->setShared('session', function () {
$session = new Session();
if (!$session->isStarted()) {
$session->start();
}
return $session;
});
}
示例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;
}
示例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);
}
示例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();
}
示例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']);
}
}
示例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;
};
}
示例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;