We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How can I execute code after the response is already sent to browser?

I want to do some logging when the response to client is already sent, so the browser is not blocked. How can I do that in Phalcon?

I was thinking about attaching to events, but application:afterHandleRequest event is fired before the HTML is sent, not after.

Hi dude check application:beforeSendResponse is the last event called source



544

I checked that event and, unfortunetely, it does not suit me, because it is fired before sending the response (which event's name says)

Hi dude check application:beforeSendResponse is the last event called source

well I think the only solutions is make your own application extending \Phalcon\Mvc\Application and overwrite handle method



544
edited Oct '18

just ended up with the following code in my base controller, and attaching to the event in appropriate place

public function __destruct() { $this->eventsManager->fire('myapp:finalize', $this); }