class Users
{
function Register(){
var_dump("用户注册");
echo '用户注册';
}
function Login(){
var_dump("用户登录");
echo '用户登录';
}
}
function TestYar(){
$users=new \Yar_Server(new Users());
$users->handle();
}
<?php
$micro_client_user=new Yar_Client('http://139.196.101.31:9501/testYar');
$res=$micro_client_user->Register();
echo $res ;
$res=$micro_client_user->Login();
echo $res ;
string(208) "
2020-03-15 17:27:23, OcurredError,Type: WAINING, errorFile: /home/wwwroot/www.hyperf.com/stock/app/Controller/IndexController.php, Line: 46, errorMessage: Yar_Server::handle(): headers already has been sent
"
string(16) "errorTrace:↓"
string(1759) "
1 {"function":"error_handle","args":[2,"Yar_Server::handle(): headers already has been sent","/home/wwwroot/www.hyperf.com/stock/app/Controller/IndexController.php",46,{"users":{}}]}
2 {"file":"/home/wwwroot/www.hyperf.com/stock/app/Controller/IndexController.php","line":46,"function":"handle","class":"Yar_Server","object":{},"type":"->","args":[]}
本次测试基于 swoole 环境运行的 hyperf 框架。 以下相同的代码,在 Laravel 框架中测试一切OK
3.客户端调用代码
报错代码