|
1 |
| -# CodeIgniter-Swoole |
2 | 1 |
|
3 |
| -CodeIgniter-Swoole (You need using it within CodeIgniter) |
| 2 | +## Codeigniter Swoole Adapter |
4 | 3 |
|
5 |
| -This simple package is combind with CodeIgniter. |
| 4 | +This adapter would make it easy to using swoole within Codeigniter framework. |
6 | 5 |
|
7 |
| -So that we can use Swoole in a single CI framework. |
| 6 | +With this adapter, you can start a task(CLI) any where(FPM) you want from your code. |
8 | 7 |
|
9 |
| -Normally we only want to start a single server side in CLI, |
| 8 | +That's means you can start a CLI task from a FPM process. |
10 | 9 |
|
11 |
| -but connect with multi client side. codeigniter-swoole is the one. |
12 | 10 |
|
13 |
| -Detail useage see the demo directory, if you formiliar with CI. |
14 |
| - |
15 |
| -# Useage |
| 11 | +## Install |
16 | 12 |
|
17 |
| -Please view the code in demo directory. |
| 13 | +```shell |
| 14 | +composer require lanlin/codeigniter-swoole |
| 15 | +``` |
18 | 16 |
|
19 |
| -The [b]"Swoole.php"[/b] controller |
20 | 17 |
|
21 |
| -file you must copy into your |
| 18 | +## How to |
22 | 19 |
|
23 |
| -[b]"codeigniter/application/controllers/Swoole.php"[/b] |
| 20 | +1. first, of course you must install `codeigniter-swoole` in your codeigniter project. |
| 21 | +2. (this step is option) copy these two config files `swoole.php` and `timers.php` from `src/Helper` to your `application/config` folder. |
| 22 | +3. start swoole server `php index.php swoole/server/start` |
| 23 | +4. you can use `\CiSwoole\Core\Client::send($data)` to start a task now! |
| 24 | +5. there's no step 5. |
24 | 25 |
|
25 |
| -Use this package, you can run your CI with nginx, and same time run CI |
26 |
| - |
27 |
| -in CLI. So, you can call the CI run in CLI through fpm, post data to it, |
28 |
| - |
29 |
| -make a long run time possible. |
30 | 26 |
|
31 |
| -# Require |
| 27 | +## What is a task? |
| 28 | +A task is just a method of your codeigniter controlloer, so almost any controller method can be used as a task. |
32 | 29 |
|
33 |
| -Before start the server side, you should make sure has swoole installed |
| 30 | +Let's see the code |
34 | 31 |
|
35 |
| -aready, and of course CI required. |
| 32 | +```php |
| 33 | +\CiSwoole\Core\Client::send( |
| 34 | +[ |
| 35 | + 'route' => 'your/route/uri/to/a/method' |
| 36 | + 'params' => ['test' => 666] |
| 37 | +]); |
| 38 | +``` |
36 | 39 |
|
37 |
| -# Command |
| 40 | +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. |
38 | 41 |
|
39 |
| -#------------------------------------------------------------------------------ |
| 42 | +So, that's all of it! |
40 | 43 |
|
41 |
| -CLI Command:> cd "to your ci root directory" |
42 | 44 |
|
43 |
| -CLI Command:> php index.php swoole start // start server from swoole.php |
| 45 | +## Server CLI Commands |
44 | 46 |
|
45 |
| -CLI Command:> php index.php swoole stop // stop server |
| 47 | +```shell |
46 | 48 |
|
47 |
| -CLI Command:> php index.php swoole reload // reload all workers |
| 49 | +// start the swoole server |
| 50 | +php index.php swoole/server/start |
48 | 51 |
|
49 |
| -#------------------------------------------------------------------------------ |
| 52 | +// stop the swoole server |
| 53 | +php index.php swoole/server/stop |
50 | 54 |
|
51 |
| -That's all, @end, sorry about my english. |
| 55 | +// reload all wokers of swoole server |
| 56 | +php index.php swoole/server/reload |
| 57 | + |
| 58 | +``` |
| 59 | + |
| 60 | + |
| 61 | +## License |
| 62 | + |
| 63 | +This project is licensed under the MIT license. |
0 commit comments