Skip to content

yar扩展无法在基于swoole环境的框架中使用 #150

Description

@qifengzhang007

本次测试基于 swoole 环境运行的 hyperf 框架。 以下相同的代码,在 Laravel 框架中测试一切OK

  1. 示例代码,创建一个Users类
class Users
{

    function   Register(){
        var_dump("用户注册");
        echo '用户注册';
    }

    function   Login(){
        var_dump("用户登录");
        echo '用户登录';
    }

}

2.yar扩展创建Server

    function TestYar(){
        $users=new \Yar_Server(new Users());
        $users->handle();
    }

3.客户端调用代码

<?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":[]}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions