Swoft 是一款基于 Swoole 扩展实现的 PHP 微服务协程框架。Swoft 能像 Go 同样,内置协程网络服务器及经常使用的协程客户端且常驻内存,不依赖传统的 PHP-FPM。有相似 Go 语言的协程操做方式,有相似 Spring Cloud 框架灵活的注解、强大的全局依赖注入容器、完善的服务治理、灵活强大的 AOP、标准的 PSR 规范实现等等。php
Swoft 经过长达三年的积累和方向的探索,把 Swoft 打形成 PHP 界的 Spring Cloud, 它是 PHP 高性能框架和微服务治理的最佳选择。git
2.0.7
在 2.0.6
上继续扬帆,已在大量的生产业务中使用,获得不少用户的确定和支持。正式版本咱们作了许多改进和优化,拥有了更好的性能。github
经过 Composer 安装 swoft/session 组件web
composer require swoft/session
Swoft\Http\Session\SessionMiddleware
中间件加入到全局中间件在配置文件 app/bean.php
里:redis
'httpDispatcher' => [
// Add global http middleware
'middlewares' => [
\Swoft\Http\Session\SessionMiddleware::class,
],
],
复制代码
默认是基于本地文件驱动,保存在
runtime/sessions
目录数据库
更在驱动只须要配置对应 handler
类,例如配置 Redis
驱动:json
'sessionHandler' => [
'class' => RedisHandler::class,
// Config redis pool
'redis' => bean('redis.pool')
],
复制代码
配置于 app/bean.php
:数组
/** @see \Swoft\WebSocket\Server\WsMessageDispatcher */
'wsMsgDispatcher' => [
'middlewares' => [
\App\WebSocket\Middleware\GlobalWsMiddleware::class
],
],
复制代码
/** * Class HomeController * * @WsController(middlewares={DemoMiddleware::class}) */
class TestController {}
复制代码
配置于 app/bean.php
:浏览器
/** @see \Swoft\Tcp\Server\TcpDispatcher */
'tcpDispatcher' => [
'middlewares' => [
\App\Tcp\Middleware\GlobalTcpMiddleware::class
],
],
复制代码
/** * Class DemoController * * @TcpController(middlewares={DemoMiddleware::class}) */
class DemoController {
// ....
}
复制代码
升级提示:服务器
Swoole\WebSocket\Server::push
第四个参数 $finish
在 swoole 4.4.12
后改成了 int 类型。TcpServerEvent::CONNECT
事件参数保持跟receive, close一致。 $fd, $server
互换位置。修复(Fixed):
ArrayHelper::get
传入key为 integer 时,报参数错误 a44dcadisEnable()
不生效的问题 da8c51e56uniqid()
方法必须将第二个参数设置为 true c7f688fresponse->delCookie()
没法删除浏览器的cookie数据问题 8eb9241JSON
格式小问题a3fc6b9rpc
服务提供者 getList
调用两次问题fd03e71redis cluster
不支持 auth
参数7a678fjson
类型, 不支持 array
6023a9multi
操做没有及时是否链接 e5f698expireAt
, geoRadius
749241crontab
时间戳检测误差问题 eb08a46更新(Update):
ConsoleEvent::SHOW_HELP_BEFORE
d3f7bc3newFromArray
和 toArray
方法,方便经过第三方存储(redis
)时导出信息和恢复链接 a8b0b7c加强(Enhancement):