mintyphp/session-handlers 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

mintyphp/session-handlers

最新稳定版本:v1.0.4

Composer 安装命令:

composer require mintyphp/session-handlers

包简介

Better session handlers

README 文档

README

This repository contains a set of PHP session save handlers that support locking. I also contains a test suite to prove that they do. Current handlers that can be tested (and their corresponding test mode) are:

Note that the standard mode testable handlers implement strict mode as well, but can't be tested as strict handlers.

Requirements

You can install the dependencies of this script using:

sudo apt install php-cli php-curl

Optional dependencies can be installed using:

sudo apt install memcached php-memcached redis php-redis

You need PHP 7.4 or higher to run the code.

Using the handlers

This package is on Packagist and can be installed using Composer, using:

composer require mintyphp/session-handlers

You can use the Redis handler by adding these two lines to your PHP code:

ini_set('session.save_path', 'tcp://localhost:6379');
ini_set('session.use_strict_mode', true);
session_set_save_handler(new RedisSessionHandler(), true);

Note that these lines must be executed before the "session_start()" call.

Running the tests

You can run the tests from the command line using:

php run-tests.php

The code will execute in about 1 second per handler and test 104 HTTP calls for each handler. The following output means that the tests succeeded:

standard - default    : OK
standard - memcachedn : OK
standard - redisn     : OK
strict   - files      : OK
strict   - memcached  : OK
strict   - redis      : OK

The word "FAILED" appears on a failed test and "SKIPPED" is shown when the PHP module is not loaded for either Redis or Memcache.

Stress testing

Use this for 100 runs:

for i in `seq 1 100`; do php run-tests.php silent; done

As shown, you may use the argument "silent" to suppress output on successful or skipped tests.

Links to other locking handlers

Below you find a few other implementations of locking Session handlers:

Enjoy!

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-09