基于协程和swoole驱动的高性能PHP框架TSF.zip

时间:2022-08-08 00:07:51
【文件属性】:
文件名称:基于协程和swoole驱动的高性能PHP框架TSF.zip
文件大小:180KB
文件格式:ZIP
更新时间:2022-08-08 00:07:51
开源项目 tsf (Tencent Server Framework) 是腾讯公司推出的 PHP 协程方案,基于 Swoole PHP Generator 实现的 Coroutine。Tencent Server Framework 是快速服务器部署框架,PHP 现在可以像 Golang 一样用协程实现高并发服务器,同时支持同步阻塞,异步非阻塞回调,协程这 3 种 IO 模型。 主要特性: 基于 PHP,相比 C 开发更高效 基于 Swoole 扩展,强大的异步 IO 支持 PHP coroutine 支持服务器监控器和提供接口 要求: php5.5 Swoole1.7.18 linux,OS X 服务器配置: vim server.ini [server] ;server type:tcp,udp,http type = http ; port listen[] = 12312 ; entrance file root = '/data/web_deployment/serv/test/index.php' ;php start path php = '/usr/local/php/bin/php' [setting] ; worker process num worker_num = 16 ; task process num task_worker_num = 0 ; dispatch mode dispatch_mode = 2 ; daemonize daemonize = 1 ; system log log_file = '/data/log/test.log' 启动服务器: cd /root/tsf/bin/ php swoole testHttpServ start 使用 TCP/UDP/HTTP 客户端:   $tcpReturn=(yield $this->tcpTest());   $udpReturn=(yield $this->udpTest());   $httpReturn=(yield $this->httpTest());   public function tcpTest(){     $ip = '127.0.0.1';     $port = '9905';     $data = 'test';     $timeout = 0.5; //second     yield new Swoole\Client\TCP($ip, $port, $data, $timeout);   }   public function udpTest(){     $ip = '127.0.0.1';     $port = '9905';     $data = 'test';     $timeout = 0.5; //second     yield new Swoole\Client\UDP($ip, $port, $data, $timeout);   }   public function httpTest(){     $url='http://www.qq.com';     $httpRequest= new Swoole\Client\HTTP($url);     $data='testdata';     $header = array(       'Content-Length' => 12345,     );     yield $httpRequest->get($url); //yield $httpRequest->post($path, $data, $header);   }
【文件预览】:
tsf-master
----bin()
--------swoole.php(17KB)
----conf()
--------testHttpServ.ini(546B)
----examples()
--------src()
----image()
--------config.jpg(36KB)
--------press.jpg(98KB)
----readme.md(5KB)
----LICENSE.TXT(4KB)
----lib()
--------tsf()
--------php()
--------Swoole()

网友评论