Swoft通过官方文档进行学习,这里不做介绍,直接上手。
涉及到Swoft方面:(配置、注意的坑)
1、控制器(路由、验证器、中间件)
4、协程简单实现
5、RPC实现
准备: 1、先安装php各种扩充,有的扩充不兼容需要禁用
2、先安装 swoftcli,能让修改代码重新启动,生效。https://www.swoft.org/docs/2.x/zh-CN/tool/swoftcli/index.html
一、Http/Https服务控制器
1、配置,在 /app/bean.php中
'httpServer' => [ 'class' => HttpServer::class, 'port' => 18306, 'listener' => [ ], 'process' => [ ], 'on' => [ ], // 'type' => SWOOLE_SOCK_TCP | SWOOLE_SSL, //支持https,必须安装OpenSSL扩充 /* @see HttpServer::$setting */ 'setting' => [0 'worker_num' => 4, //支持https,签名文件 // 'ssl_cert_file' => '/my/certs/2288803_www.domain.com.pem', // 'ssl_key_file' => '/my/certs/2288803_www.domain.com.key', ] ],