本文整理汇总了PHP中Phalcon\Session\Adapter\Files::start方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::start方法的具体用法?PHP Files::start怎么用?PHP Files::start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Session\Adapter\Files
的用法示例。
在下文中一共展示了Files::start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
});
}
示例3: initSession
/**
* Initializes the session
*
* @param array $options
*/
protected function initSession($options = array())
{
$this->di['session'] = function () {
$session = new PhSession();
$session->start();
return $session;
};
}
示例4: 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;
});
}
示例5: onBoot
public function onBoot()
{
// TODO: Implement onBoot() method.
$this->getDI()->setShared('session', function () {
$session = new Session();
if (!$session->isStarted()) {
$session->start();
}
return $session;
});
}
示例6: 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;
});
}
示例7: 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;
}
示例8: start
/**
* Starts the session
* @return bool
*/
public function start()
{
// Check that session is not already started
if ($this->isStarted()) {
return false;
}
// Get current cookie options
$options = $this->getCookieOptions();
// Set cookie name
session_name($options['name']);
// Set cookie parameters
session_set_cookie_params($options['lifetime'], $options['path'], $options['domain'], $options['secure'], $options['httponly']);
// Start session
return parent::start();
}
示例9: 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;
};
}
示例10: _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;
}
示例11: initSession
/**
* Initializes the session
*
* @param array $options
*/
protected function initSession($options = array())
{
$config = $this->di['config'];
$this->di['session'] = function () use($config) {
$session = new PhSession(array('uniqueId' => $config->application->appName));
$session->start();
return $session;
};
}
示例12: 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);
}
示例13: registerServices
/**
* Register services used by the frontend application
*
* @param $di
*/
public function registerServices(FactoryDefault $di)
{
$config = $this->config();
/**
* register the dispatcher
*/
$di->set('dispatcher', function () {
$dispatcher = new Dispatcher();
/*$eventManager = new Manager();
$eventManager->attach('dispatch', new \Acl('frontend'));
$dispatcher->setEventsManager($eventManager);*/
$dispatcher->setDefaultNamespace('app\\frontend\\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' => '_']);
/**
* add functions to compiler
*/
VoltHelper::registerViewFunctions($volt, VoltHelper::getUtil(['ng']));
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;
});
/**
* Set the auth component
*/
$di->set('auth', function () {
$auth = new Auth();
$auth->setSuccessUrl('/index/index');
$auth->setFailUrl('session/login');
return $auth;
});
// /**
// * List of assets that need to be loaded
// */
// $di->setShared('asset_config', function () {
// return require_once(APP_PATH . '/frontend/config/assets.php');
// });
}
示例14: register
public function register()
{
$session = new SessionAdapter();
$session->start();
return $session;
}
示例15: load
public static function load(&$di, &$config)
{
/**
* 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);
/**
* Setting up the view component
*/
$di->set('view', function () use($config) {
$view = new View();
$view->setViewsDir($config->application->viewsDir);
return $view;
}, true);
/**
* Database connection is created based in the parameters defined in the configuration file
*/
$di->set('db', function () use($config) {
$db = new DbAdapter((array) $config->database);
$db->timeout = $config->database->timeout;
$db->start = time();
$eventsManager = new \Phalcon\Events\Manager();
$eventsManager->attach('db', function ($event, $db) {
if ($event->getType() == 'beforeQuery') {
$idle = time() - $db->start;
if ($idle > $db->timeout) {
$db->connect();
$db->start = time();
}
}
return true;
});
return $db;
});
/**
* 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->set('session', function () {
$session = new SessionAdapter();
$session->start();
return $session;
});
/**
* Set encryption
*/
$di->set('crypt', function () {
$crypt = new Phalcon\Crypt();
$crypt->setKey('&fhm8.2$m62$/,1@');
return $crypt;
}, true);
/**
* Set security component to validate / generate tokens
*/
$di->set('secure', function () {
return new SecurityComponent();
});
}