nguyenanhung/codeigniter3-swoole
Composer 安装命令:
composer require nguyenanhung/codeigniter3-swoole
包简介
Swoole Adapter for CodeIgniter v3 Framework - Basic, Simple and Lightweight
README 文档
README
Swoole Adapter for CodeIgniter v3 Framework
You want long-run task? timers? FPM to CLI? Code reusing in both FPM & CLI mode?
"It's so easy!"
This adapter would make it so easy to using swoole within Codeigniter framework.
With this adapter, you can start a task(CLI) anywhere (FPM) you want from your code.
That's means you can start a CLI task from a FPM process.
Install
composer require nguyenanhung/codeigniter3-swoole
How to
- first, of course you must install
codeigniter3-swooleto your codeigniter project. - (this step is option) copy these two config files
swoole.phpandtimers.phpfromconfigto yourapp/configfolder. - start swoole server
php index.php swoole/server/start - you can use
\nguyenanhung\CodeIgniter\Swoole\Core\Client::send($data)to start a task now! - there's no step 5.
What is a task?
A task is just a method of your codeigniter controlloer, so almost any controller method can be used as a task.
Let's see the code
\nguyenanhung\CodeIgniter\Swoole\Core\Client::send( [ 'route' => 'your/route/uri/to/a/method' 'params' => ['test' => 666] ]);
The route is used for find which method to be call as a task, and params is the parameters array that you may want to pass to the task.
So, that's all of it!
Server CLI Commands
// start the swoole server php index.php swoole/server/start // stop the swoole server php index.php swoole/server/stop // reload all wokers of swoole server php index.php swoole/server/reload
A little more
The step 2 copied files were config files for this adapter.
swoole.php file can set host, port, log file and so on.
timers.php file can set some timer methods for swoole server, these timers will be started once the server inited.
The demos are same as below shows.
class Test extends CI_Controller { // ------------------------------------------------------------------------------ /** * here's the task 'tests/test/task' */ public function task() { $data = $this->input->post(); // as you see, params worked like normally post data log_message('info', var_export($data, true)); } // ------------------------------------------------------------------------------ /** * here's the timer method * * you should copay timers.php to your config folder, * then add $timers['tests/test/task_timer'] = 10000; and start the swoole server. * * this method would be called every 10 seconds per time. */ public function task_timer() { log_message('info', 'timer works!'); } // ------------------------------------------------------------------------------ /** * send data to task */ public function send() { try { \nguyenanhung\CodeIgniter\Swoole\Core\Client::send( [ 'route' => 'tests/test/task', 'params' => ['hope' => 'it works!'], ]); } catch (\Exception $e) { log_message('error', $e->getMessage()); log_message('error', $e->getTraceAsString()); } } // ------------------------------------------------------------------------------ }
Contact & Support
If any question & request, please contact following information
| Name | Skype | ||
|---|---|---|---|
| Hung Nguyen | dev@nguyenanhung.com | nguyenanhung5891 | @nguyenanhung |
From Vietnam with Love <3
nguyenanhung/codeigniter3-swoole 适用场景与选型建议
nguyenanhung/codeigniter3-swoole 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 07 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「library」 「helper」 「swoole」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nguyenanhung/codeigniter3-swoole 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nguyenanhung/codeigniter3-swoole 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nguyenanhung/codeigniter3-swoole 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Datetime helpers for timezone handling
Library with classes to help you do batch.
This adds functions about array. If you feel like there few php built-in functions about array, this will be useful.
HTML and form generation
Inbox pattern process implementation for your Laravel Applications
Core library that defines common interfaces used by the rest of the intahwebz..
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-25