Skip to content

Possibility to run defer tasks after response #168

Description

@armanist

Implement the ability to register and execute callbacks that run after the HTTP response is sent to the client, without blocking the request lifecycle.

This allows long-running or non-essential tasks (e.g. logging, sending emails, dispatching events) to be deferred, improving response time and user experience.

Acceptance Criteria:

  • Introduce a new internal hook named after_response (or similar).

  • Allow developers to register callbacks using HookManager::on('after_response', callable).

  • Ensure multiple parts of the codebase can register deferred tasks safely.

  • Execute all deferred callbacks after $response->send() in the lifecycle.

  • Wrap execution in try/catch to prevent deferred task failures from affecting app behavior.

  • Add config entry for after_response hook (optional, or register programmatically).

Activity

  1. armanist commented on Nov 1, 2024

    @armanist
    CollaboratorAuthor

    Add ability to define defer tasks which will be called after response cycle ends.

  2. added this to the 2.9.8 milestone on Mar 13, 2025
  3. modified the milestones: 2.9.8, 2.9.9 on Aug 27, 2025
  4. modified the milestones: 2.9.9, 3.0.0 on Nov 24, 2025
  5. removed this from the 3.0.0 milestone on May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions