定制 phalcon/incubator-session 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phalcon/incubator-session

最新稳定版本:v3.0.0

Composer 安装命令:

composer require phalcon/incubator-session

包简介

Phalcon Incubator Sessions Adapters

README 文档

README

Discord Packagist Version PHP from Packagist codecov Packagist

Issues tracker

https://github.com/phalcon/incubator/issues

Database

This adapter uses a database backend to store session data:

use Phalcon\Db\Adapter\Pdo\Mysql;
use Phalcon\Incubator\Session\Adapter\Database;

$di->set('session', function () {
    // Create a connection
    $connection = new Mysql([
        'host'     => 'localhost',
        'username' => 'root',
        'password' => 'secret',
        'dbname'   => 'test',
    ]);

    $session = new Database($connection, 'session_data');
    $session->start();

    return $session;
});

This adapter uses the following table to store the data:

 CREATE TABLE `session_data` (
  `session_id` VARCHAR(35) NOT NULL,
  `data` text NOT NULL,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `modified_at` TIMESTAMP NULL DEFAULT NULL,
  PRIMARY KEY (`session_id`)
);

Upgrading from phalcon/incubator 3.4 will require changes to the session_data table:

ALTER TABLE session_data MODIFY COLUMN created_at TIMESTAMP DEFAULT current_timestamp() NOT NULL;
ALTER TABLE session_data MODIFY COLUMN modified_at TIMESTAMP DEFAULT NULL NULL;

Mongo

Install PHP MongoDB Extension via pecl:

pecl install mongodb

After install, add the following line to your php.ini file:

extension=mongodb.so

This adapter uses a Mongo database backend to store session data:

use Phalcon\Incubator\Session\Adapter\Mongo as MongoSession;

$di->set('session', function () {
    // Create a connection to mongo
    $mongo = new \MongoDB\Client(
        'mongodb+srv://<username>:<password>@<cluster-address>/test?retryWrites=true&w=majority'
    );

    // Passing a collection to the adapter
    $session = new MongoSession([
        'collection' => $mongo->test->session_data,
    ]);
    $session->start();

    return $session;
});

统计信息

  • 总下载量: 286.62k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 5
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2020-05-24