dracony on 3.7.2
dracony on master
Updated composer.json to get de… Swithced to dorantor branch for… Fixed curly braces access error… and 2 more (compare)
dracony on 3.8
dracony on master
social provider VK api fix ver… VK, users.get backwards compati… Merge pull request #11 from kip… (compare)
Hi All. What is a proper way to work with Response? According to what I see in code it's not what promised in docs. For example, this will not work:
$response->headers->set('Content-Type', 'text/csv'); // ->headers are protected property // ->set() there is no such method
If you have created response with
$response = $responses->string('hello world');
You also cannot set headers.
Currently I'm accumulating headers separately and building response object right at the end of processor action logic, just before return. But that's feels lame. Am I missing something?
A-ha. This is the part I've missed, thanks.
And what about body? Is it proper way?
// inside Processor action method $this->response = $this->responses()->string(''); //... $this->response->body()->write($someString);
What would be proper way and moment to create response within React like environment? Should it be within
__constructor() or inside
process() where I already catch and save Request for further processing. Or, maybe, there is a better way to access current Request object inside action method?
Why do you need to write() after building the string response? If its to stream data incrementally there are better reponse types in the Responses class
Because I need response to attach headers first. And, at the last moment, when everything else is in place(within Response object) I'm adding last piece - body. In my flow, headers and body are set separately in different places.
I think the best would be to create the Reaponse as late as possible just before returning vs mutating it
This is what I do now - collect headers in array and create Response just before Action return. But it feels slightly wrong - instead of single object responsible for response I have few.
But its just preference. There is nothing special about the response class itself really. I would definitely create it in process() then in constructor. Constructor to me seems to be just for wiring things and technically a single processor can serve multiple requests in sequential calls to process()
Good point, actually. Especially according to my context, where I'm trying to run application inside RoadRunner(React-like environment). So it's not just preference.
return array( //You can define multiple connections //each with a different name 'default' => array( 'driver' => 'pdo', //MySQL 'connection' => 'mysql:host=localhost;dbname=phpixie;charset=utf8mb4', 'user' => 'root', 'password' => 'password' ));
./console framework:seed return [ [ 'id' => 1, 'userId' => 1, 'text' => "Hello World!", 'date' => '2016-12-01 10:15:00' ], // .... ][ERROR]: count(): Parameter must be an array or an object that implements Countable
/var/log/nginx/nginx_error.log 2021/08/28 18:25:31 [error] 31206#31206: *1 directory index of "/home/admin/habib/project/web/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost:870"
try_filesdirective would solve the problem.