gotzmann / comet

Modern PHP framework for building blazing fast REST APIs and microservices
MIT License
661 stars 52 forks source link

Problem with example controller #28

Closed joecoolio closed 2 years ago

joecoolio commented 2 years ago

There is another closed issue on this but I think I see the same thing:

Using SimpleController.php exactly as in the readme, I get this on the GET request: GET http://10.1.2.23:8080/api/v1/counter Returns 500 Log from the web server says:

[ERR] /home/wordgame/webtest/vendor/gotzmann/comet/src/Stream.php:250 >> fwrite(): Argument #2 ($data) must be of type string, int given

I'm not sure exactly what I'm supposed to do with that.

Using the earlier example this doesn't happen. Also, the POST from the controller works fine too. $app->get('/json', function ($request, $response) {
$data = [ "message" => "Hello, Comet!" ]; return $response ->with($data); }); ----works

joecoolio commented 2 years ago

I think I figured it out 5 minutes after posting this: $response->getBody()->write((string)self::$counter);
Write needs a string, not an integer.