renegare / silexcsh
Silex 的 Cookie 会话处理器(客户端存储会话数据)
v0.1.1
2014-10-09 13:23 UTC
Requires
- php: >=5.4.0
- psr/log: 1.0.0
Requires (Dev)
- phpunit/phpunit: 3.7.*
- silex/silex: >=1.0
- symfony/browser-kit: >=2.3,<2.6-dev
- symfony/http-foundation: >=2.4,<2.6-dev
This package is not auto-updated.
Last update: 2024-09-24 02:37:08 UTC
README
Silex Cookie 会话处理器
要求
- PHP 5.4
- composer(推荐使用最新版)
安装
$ composer require renegare/silexcsh:dev-master
使用示例
Silex 使用
<?php
$app = new Silex\Application();
$app->register(new Renegare\SilexCSH\CookieSessionServiceProvider, [
'session.cookie.options' => [
'name' => 'CUSTOMNAME', // string
'lifetime' => 0, // int
'path' => '/', // string
'domain' => null, // string
'secure' => false, // boolean
'httponly' => true // boolean
]
]);
$app->get('/doing-nothing', function(Application $app) {
return 'Nothing going on here with sessions';
});
$app->get('/persist', function(Application $app){
$app['session']->set('message', 'Hello There!');
return 'Check your cookie!';
});
$app->get('/read', function(Application $app){
return print_r($app['session']->all(), true);
});
$app->get('/destroy', function(Application $app) {
$app['session']->clear();
return 'Ok Bye Bye!';
});
测试
查看仓库,然后在顶级目录下运行以下命令(需要 xdebug 以进行覆盖率分析)
$ composer update && vendor/bin/phpunit --coverage-text