The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

How to execute code after sending the response to the HTTP client

acorrea's Avatar

acorrea

01 Feb, 2016 05:17 PM

Hello,

I want to execute some code after sending a response to the HTTP client, but I'm not sure that's even possible with the middleware model used in Slim. Is it possible? How?

Note: I don't want to do something that should be done with queues, the code that I want to execute is lightweight, BUT, for latency restrictions I prefer to execute it after responding to the HTTP client.

Thank you for your time and wisdom!

  1. 1 Posted by acorrea on 01 Feb, 2016 05:27 PM

    acorrea's Avatar

    Extra comment: A possible solution that I'm glimpsing is doing something like:

    $app->finalize($response);
    $app->respond($response);

    inside the "action / controller", but I don't know if this is a good idea, since this involves passing a reference to the Slim\App instance to the controller.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac