quantum-php / quantum-php/framework

Possibility to run defer tasks after response

Open
#168 1 comment 0 reactions 2 assignees View on GitHub

@andrey-smaelov is already working on this.

Since Nov 1, 2024.

good first issue new feature
Dominant language
PHP
Stars
36
Forks
22
PR merge metrics
No merged PRs in 30d

Description

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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.