{"id":29017090,"url":"https://github.com/tencent-php/tsf","last_synced_at":"2025-06-25T23:03:31.988Z","repository":{"id":34535188,"uuid":"38478437","full_name":"Tencent/tsf","owner":"Tencent","description":"coroutine and Swoole based php server framework in tencent","archived":true,"fork":false,"pushed_at":"2019-10-24T03:46:39.000Z","size":298,"stargazers_count":2161,"open_issues_count":27,"forks_count":480,"subscribers_count":260,"default_branch":"master","last_synced_at":"2025-06-19T03:03:46.189Z","etag":null,"topics":["coroutines","php","swoole"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tencent.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-03T07:15:44.000Z","updated_at":"2025-06-12T09:51:24.000Z","dependencies_parsed_at":"2022-09-08T14:02:14.784Z","dependency_job_id":null,"html_url":"https://github.com/Tencent/tsf","commit_stats":null,"previous_names":["tencent-php/tsf"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Tencent/tsf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2Ftsf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2Ftsf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2Ftsf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2Ftsf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tencent","download_url":"https://codeload.github.com/Tencent/tsf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2Ftsf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261967097,"owners_count":23237661,"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","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":["coroutines","php","swoole"],"created_at":"2025-06-25T23:01:26.440Z","updated_at":"2025-06-25T23:03:31.979Z","avatar_url":"https://github.com/Tencent.png","language":"PHP","readme":"项目目前是存档状态，感谢您对腾讯开源项目的关注！您可以继续fork后更新迭代，感谢理解和支持；如果您有其他疑问，建议请发送邮件：tencentopen@tencent.com 与我们联系\n\n-----\n\n\nTencent Server Framework\n=======================\n\n## Overview\n\nTencent Server Framework is a coroutine and Swoole based server framework for fast server deployment which developed by Tencent engineers.\n\n## Features\n\n- PHP Based. Compared with C++, the framework is more efficient in developing and programing.\n- based on Swoole extension. powerful async IO, timers and other infrastructure capacity can be used in this framework.\n- support PHP coroutine. Synchronous programing is possible using the coroutine schedule system, and can lead to the similar server capability with that of server deveoped in an asynchronous way.\n- support server monitor and provide interface to add more rules \n\n\n## Requirements\n\n- php5.5+ \n- Swoole1.7.18+\n- linux,OS X\n\n## Installation\n- [PHP install](https://github.com/php/php-src)\n- [Swoole extension install](https://github.com/swoole/swoole-src)\n\n## Introduction\n\n- Tencent Server Framework can help you to start your server quickly,you just need to set a few settings\n\n### Server config\n\n```php\nvim server.ini\n\n[server]\n;server type:tcp，udp，http\ntype = http\n; port\nlisten[] = 12312\n; entrance file\nroot = '/data/web_deployment/serv/test/index.php'\n;php start path\nphp = '/usr/local/php/bin/php'\n\n[setting]\n; worker process num\nworker_num = 16\n; task process num\ntask_worker_num = 0\n; dispatch mode\ndispatch_mode = 2\n; daemonize\ndaemonize = 1\n; system log\nlog_file = '/data/log/test.log'\n\n```\n#### How to start your server\n```php\ncd /root/tsf/bin/\nphp swoole testHttpServ start\n\n```\n- Support Cmds: start,stop,reload,restart,status,shutdown,startall,list\n\n#### How to use TCP/UDP/HTTP Client\n- we support different network protocols: TCP,UDP,HTTP\n\n```php\n\n  $tcpReturn=(yield $this-\u003etcpTest());\n  \n  $udpReturn=(yield $this-\u003eudpTest());\n\n  $httpReturn=(yield $this-\u003ehttpTest());\n\n  public function tcpTest(){\n    $ip = '127.0.0.1';\n    $port = '9905';\n    $data = 'test';\n    $timeout = 0.5; //second\n    yield new Swoole\\Client\\TCP($ip, $port, $data, $timeout);\n  }\n  \n  public function udpTest(){\n    $ip = '127.0.0.1';\n    $port = '9905';\n    $data = 'test';\n    $timeout = 0.5; //second\n    yield new Swoole\\Client\\UDP($ip, $port, $data, $timeout);\n  }\n  \n  public function httpTest(){\n    $url='http://www.qq.com';\n    $httpRequest= new Swoole\\Client\\HTTP($url);\n    $data='testdata';\n    $header = array(\n      'Content-Length' =\u003e 12345,\n    );\n    yield $httpRequest-\u003eget($url); //yield $httpRequest-\u003epost($path, $data, $header);\n  }\n\n\n\n```\n\n#### How to use Muticall\n\n- Beside that,we also support Muticall:\n- you can use Muticall to send TCP,UDP packets at the sametime\n- when all the requests come back,return to interrupt\n\n```php\n  \n  $res = (yield $this-\u003emuticallTest());\n  \n  public function muticallTest(){\n    $calls=new Swoole\\Client\\Multi();\n    $firstReq=new Swoole\\Client\\TCP($ip, $port, $data, $timeout);\n    $secondReq=new Swoole\\Client\\UDP($ip, $port, $data, $timeout);\n    $thirdReq= new Swoole\\Client\\HTTP(\"http://www.qq.com\");\n\n    $calls -\u003erequest($firstReq,'first');             //first request\n    $calls -\u003erequest($secondReq,'second');             //second request\n    $calls -\u003erequest($thirdReq,'third');             //third request\n    yield $calls;\n  }\n\n  var_dump($res)\n  \n```\n#### Concect to mysql async \n\n```php\n\n    $sql = new Swoole\\Client\\MYSQL(array('host' =\u003e '127.0.0.1', 'port' =\u003e 3345, 'user' =\u003e 'root', 'password' =\u003e 'root', 'database' =\u003e 'test', 'charset' =\u003e 'utf-8',));\n    $ret = (yield $sql -\u003equery('show tables'));\n    var_dump($ret);\n    $ret = (yield $sql -\u003equery('desc test'));\n    var_dump($ret);\n    \n```\n\n#### Router\n- We support individuation route rules\n- now we realize some universal route rules and restful rules\n- besides that, we also support default GET parameter\n\n```php\n  URL                                       METHOD       CONTROLLER  ACTION\n  http://127.0.0.1:80/Test?h=1              ANY     ==\u003e  TestController/ActionIndex\n\n  http://127.0.0.1:80/Test/send?h=1         ANY     ==\u003e  TestController/ActionSend\n  Restful\n  http://127.0.0.1:80/rest                  GET     ==\u003e  TestController/ActionList\n  http://127.0.0.1:80/rest/Test/22          GET     ==\u003e  TestController/ActionView\n                                                         Get['id']=22\n  http://127.0.0.1:80/rest/Test             POST    ==\u003e  TestController/ActionCreate\n  http://127.0.0.1:80/rest/Test/22          PUT     ==\u003e  TestController/ActionUpdate\n                                                         Get['id']=22\n  http://127.0.0.1:80/rest/Test/22          DELETE  ==\u003e  TestController/ActionDelete\n                                                         Get['id']=22\n  http://127.0.0.1:80/rest/Test/send/1/li   GET     ==\u003e  TestController/ActionSend\n                                                         Get['cid']=1 Get['name']=li\n\n\n```\n## Performance \n\n\n## Contribution\n\nYour contribution to TSF development is very welcome!\n\nYou may contribute in the following ways:\n\n* [Repost issues and feedback](https://github.com/tencent-php/tsf/issues)\n* Submit fixes, features via Pull Request\n* Write/polish documentation\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencent-php%2Ftsf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftencent-php%2Ftsf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencent-php%2Ftsf/lists"}