
swoole
大熊不是猫
这个作者很懒,什么都没留下…
展开
-
3.swoole安装【Docker】
docker安装swoole原创 2024-10-23 01:54:28 · 591 阅读 · 0 评论 -
16. Redis异步队列
hyperf redis异步队列原创 2024-10-22 01:32:25 · 863 阅读 · 0 评论 -
15. 缓存(Cache)
hyperf 缓存 cache原创 2024-10-22 01:20:28 · 966 阅读 · 0 评论 -
14. Task机制
hyperf task原创 2024-10-22 01:16:59 · 426 阅读 · 0 评论 -
13. Request请求与Response响应
hyperf request response原创 2024-10-22 01:08:37 · 228 阅读 · 0 评论 -
12. 命令行
hyperf 命令行原创 2024-10-22 01:04:36 · 479 阅读 · 0 评论 -
11. 事件机制
hyperf 事件机制原创 2024-10-22 01:01:50 · 658 阅读 · 0 评论 -
10. 异常处理器
hyperf 异常处理器原创 2024-10-22 00:57:26 · 396 阅读 · 0 评论 -
9. JSON RPC 服务
hyperf jsonRPC原创 2024-10-22 00:52:13 · 1324 阅读 · 0 评论 -
8. 中间件
hyperf 中间件原创 2024-10-22 00:38:30 · 731 阅读 · 0 评论 -
7. 配置
hyperf 获取配置项原创 2024-10-22 00:32:33 · 433 阅读 · 0 评论 -
6. 协程
hyperf 协程原创 2024-10-22 00:28:04 · 316 阅读 · 0 评论 -
5. AOP
hperf AOP原创 2024-10-22 00:07:21 · 534 阅读 · 0 评论 -
4. 自定义注解
注解类需继承 Hyperf\Di\Annotation\AbstractAnnotation 类 指定本类的使用场景原创 2024-10-22 00:04:41 · 220 阅读 · 0 评论 -
3. IoC 与DI
hyperf ioC与DI原创 2024-10-22 00:01:47 · 1060 阅读 · 0 评论 -
2. 什么是注解?
hyperf 什么是注解原创 2024-10-21 23:50:51 · 148 阅读 · 0 评论 -
1. 路由定义
hyperf 路由定义原创 2024-10-21 23:45:04 · 399 阅读 · 0 评论 -
swoole table 内存表
<?php// 创建内存表 1024 指定表格的最大行数$table = new Swoole\Table(1024);/** * 内存表增加一列 * 参数一 字段的名称 * 参数二 字段类型 Table::TYPE_INT, Table::TYPE_FLOAT, Table::TYPE_STRING * 参数三 字段的最大长度 */$table->column('id', $table::TYPE_INT, 4);$table->column('name',原创 2021-03-17 10:41:00 · 243 阅读 · 0 评论 -
swoole process 进程 测试代码
<?php// 多进程应用 循环数据处理class DataDispose{ public function index() { echo '测试开始--'. date('Y-m-d H:i:s'). PHP_EOL; // 生成测试数组 $datas = range(0, 9); foreach ($datas as $data) { // 开启子进程 $proces原创 2021-03-16 17:00:00 · 145 阅读 · 0 评论 -
swoole process 单进程
<?phpclass Process{ public $process = null; public function __construct() { /** * 实例化进程管理对象 * 参数一,callable $function 子进程创建成功后要执行的函数 * 参数二,是否将结果放入进程管道中 false为直接输出 */ $this->process = n原创 2021-03-16 15:38:36 · 215 阅读 · 0 评论 -
swoole 毫秒定时器
<?phpclass Ws{ const HOST = '0.0.0.0'; // 监听的IP地址, 0.0.0.0 表示监听所有IP地址 const PROT = '9504'; public $ws = null; // 存放websocket连接资源 public $config = [ // 进程数 'worker_num' => 2, ]; public function __construct() {原创 2021-03-15 16:38:03 · 206 阅读 · 0 评论 -
swoole Task 任务
<?phpclass Ws{ const HOST = '0.0.0.0'; // 监听的IP地址, 0.0.0.0 表示监听所有IP地址 const PROT = '9504'; public $ws = null; // 存放websocket连接资源 public $config = [ // 进程数 'worker_num' => 2, // Task 进程的数量 'task_worker_num'原创 2021-03-15 15:44:40 · 206 阅读 · 0 评论 -
WebSocket 客户端
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>websocket</title></head><body> <h1>swoole - websocket</h1> <script> var wsUrl = 'ws://xxx.xx.x原创 2021-03-15 15:21:40 · 251 阅读 · 0 评论 -
swoole WebSocket 服务器
<?phpclass Ws{ const HOST = '0.0.0.0'; // 监听的IP地址, 0.0.0.0 表示监听所有IP地址 const PROT = '9504'; public $ws = null; // 存放websocket连接资源 // websocket 继承自 http 服务,所以 http 提供的所有 API 和配置项都可以使用, // websocket 同样支持静态文件的访问。 public $config = [原创 2021-03-15 15:07:07 · 169 阅读 · 0 评论 -
swoole HTTP服务器
<?phpclass Http{ const HOST = '0.0.0.0'; // 监听的IP地址, 0.0.0.0 表示监听所有IP地址 const PROT = '9503'; public $http = null; // 存放http连接资源 public $config = [ // 进程数 'worker_num' => 8, // 开启静态文件请求 'enable_sta原创 2021-03-12 15:27:10 · 222 阅读 · 0 评论 -
swoole UDP客户端
<?phpclass UdpClient{ const HOST = '127.0.0.1'; const PROT = '9502'; public $client = null; // 存放upd连接资源 public function __construct() { $this->client = new Swoole\Client(SWOOLE_SOCK_UDP); // 连接UDP客户端原创 2021-03-12 14:36:44 · 171 阅读 · 0 评论 -
swoole UDP服务器
<?phpclass Udp{ const HOST = '127.0.0.1'; const PROT = '9502'; public $udpServer = null; public $config = [ 'worker_num' => 8, // 进程数 'max_request' => 10000, // 当前 Worker 进程允许收到的最大请求次数 ]; public functio原创 2021-03-12 11:15:10 · 149 阅读 · 0 评论 -
swoole TCP客户端
<?phpclass TcpClient{ const HOST = '127.0.0.1'; const PROT = '9501'; public $client = null; // 存放tcp连接信息 public function __construct() { $this->client = new swoole\Client(SWOOLE_SOCK_TCP); if (!$this->clien原创 2021-03-11 17:39:26 · 116 阅读 · 0 评论 -
swoole TCP服务器
<?phpclass Tcp{ const HOST = '127.0.0.1'; const PROT = '9501'; public $tcpServer = null; // 存放tcp连接信息 public $config = [ 'worker_num' => 8, // 开启进程数 'max_request' => 10000 // 当前worker进程 允许收到的最大请求次数 ];原创 2021-03-11 17:01:11 · 177 阅读 · 2 评论 -
swoole配合shell_exec函数实现服务监控
咱们写一个监控WebSocket服务运行的脚本class Monitoring{ // WebSocket监听的端口 const PORT = 9510; public function port() { // 查询 端口使用情况 // grep LISTEN 过滤处于侦听状态的进程 // wc -l 是统计文件行数 $shell = 'netstat -nap | grep '. self::PORT. '原创 2021-03-08 17:42:44 · 431 阅读 · 0 评论 -
swoole 协程方式写入http系统日志
日志是一个项目中非常重要的部分,用来做分析最合适了,下面呢咱们就模仿 php fpm的方式,在swoole的http中写一个系统日志的写入功能。class HttpServer{ const HOST = '0.0.0.0'; const PROT = '9510'; public $http = null; public function __construct() { $this->http = new swoole\http\serv原创 2021-03-10 16:05:47 · 478 阅读 · 0 评论 -
swoole平滑重启
swoole中 swoole_set_process_name() 函数可以设置为进程设置名称,再通过 pidof 命令获取其pid,有了pid就可以通过 kill -10 pid 平滑重启服务。class WebsocketServer{ const HOST = '0.0.0.0'; const PROT = '9510'; public $ws = null; public function __construct() {原创 2021-03-10 17:49:23 · 673 阅读 · 0 评论