{"id":15616364,"url":"https://github.com/lanlin/codeigniter-swoole","last_synced_at":"2025-08-07T07:10:47.946Z","repository":{"id":57011193,"uuid":"43926922","full_name":"lanlin/codeigniter-swoole","owner":"lanlin","description":"Swoole Adapter For Codeigniter Framework","archived":false,"fork":false,"pushed_at":"2019-07-26T09:08:30.000Z","size":80,"stargazers_count":38,"open_issues_count":1,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-06T02:16:38.362Z","etag":null,"topics":["cli-command","codeigniter-swoole","php-long-run","php-swoole","php-task"],"latest_commit_sha":null,"homepage":"https://github.com/lanlin/codeigniter-swoole","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lanlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-09T01:57:15.000Z","updated_at":"2025-06-19T09:39:56.000Z","dependencies_parsed_at":"2022-08-21T15:10:22.668Z","dependency_job_id":null,"html_url":"https://github.com/lanlin/codeigniter-swoole","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/lanlin/codeigniter-swoole","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanlin%2Fcodeigniter-swoole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanlin%2Fcodeigniter-swoole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanlin%2Fcodeigniter-swoole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanlin%2Fcodeigniter-swoole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lanlin","download_url":"https://codeload.github.com/lanlin/codeigniter-swoole/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanlin%2Fcodeigniter-swoole/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267156150,"owners_count":24044415,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli-command","codeigniter-swoole","php-long-run","php-swoole","php-task"],"created_at":"2024-10-03T07:07:17.746Z","updated_at":"2025-07-26T11:18:42.274Z","avatar_url":"https://github.com/lanlin.png","language":"PHP","readme":"\n## Codeigniter Swoole Adapter\n\nYou want long-run task? timers? FPM to CLI? Code reusing in both FPM \u0026 CLI mode?\n\n\"It's so easy!\"\n\nThis adapter would make it so easy to using swoole within Codeigniter framework.\n\nWith this adapter, you can start a task(CLI) any where(FPM) you want from your code.\n\nThat's means you can start a CLI task from a FPM process.\n\n\n## Install\n\n```shell\ncomposer require lanlin/codeigniter-swoole\n```\n\n\n## How to\n\n1. first, of course you must install `codeigniter-swoole` to your codeigniter project.\n2. (this step is option) copy these two config files `swoole.php` and `timers.php` from `src/Helper` to your `application/config` folder.\n3. start swoole server `php index.php swoole/server/start`\n4. you can use `\\CiSwoole\\Core\\Client::send($data)` to start a task now!\n5. there's no step 5.\n\n\n## What is a task?\nA task is just a method of your codeigniter controlloer, so almost any controller method can be used as a task.\n\nLet's see the code\n\n```php\n\\CiSwoole\\Core\\Client::send(\n[\n    'route'  =\u003e 'your/route/uri/to/a/method'\n    'params' =\u003e ['test' =\u003e 666]\n]);\n```\n\nThe `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.\n\nSo, that's all of it!\n\n\n## Server CLI Commands\n\n```shell\n\n// start the swoole server\nphp index.php swoole/server/start\n\n// stop the swoole server\nphp index.php swoole/server/stop\n\n// reload all wokers of swoole server\nphp index.php swoole/server/reload\n\n```\n\n\n## A little more\n\nThe step 2 copied files were config files for this adapter.\n\n`swoole.php` file can set host, port, log file and so on.\n\n`timers.php` file can set some timer methods for swoole server, these timers will be started once the server inited.\n\nYou can copy `tests/application` to your `application` for testing. The demos are same as below shows.\n\n\n```php\nclass Test extends CI_Controller\n{\n\n    // ------------------------------------------------------------------------------\n\n    /**\n     * here's the task 'tests/test/task'\n     */\n    public function task()\n    {\n        $data = $this-\u003einput-\u003epost();     // as you see, params worked like normally post data\n\n        log_message('info', var_export($data, true));\n    }\n\n    // ------------------------------------------------------------------------------\n\n    /**\n     * here's the timer method\n     *\n     * you should copay timers.php to your config folder,\n     * then add $timers['tests/test/task_timer'] = 10000; and start the swoole server.\n     *\n     * this method would be called every 10 seconds per time.\n     */\n    public function task_timer()\n    {\n        log_message('info', 'timer works!');\n    }\n\n    // ------------------------------------------------------------------------------\n\n    /**\n     * send data to task\n     */\n    public function send()\n    {\n        try\n        {\n            \\CiSwoole\\Core\\Client::send(\n            [\n                'route'  =\u003e 'tests/test/task',\n                'params' =\u003e ['hope' =\u003e 'it works!'],\n            ]);\n        }\n        catch (\\Exception $e)\n        {\n            log_message('error', $e-\u003egetMessage());\n            log_message('error', $e-\u003egetTraceAsString());\n        }\n    }\n\n    // ------------------------------------------------------------------------------\n\n}\n```\n\n\n## License\n\nThis project is licensed under the MIT license.\n\n## 补充说明\n[codeigniter-swoole 的主要应用场景](https://github.com/lanlin/codeigniter-swoole/issues/4)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanlin%2Fcodeigniter-swoole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flanlin%2Fcodeigniter-swoole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanlin%2Fcodeigniter-swoole/lists"}