Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Introduce lifecycle hooks across boot, web runtime, console runtime, routing, and response flow

Aperta
#538 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
php
Ambito
api, backend, cli

Direzione di ricerca

Inizia leggendo src/App/BootPipeline.php, src/App/Adapters/WebAppAdapter.php, src/App/Adapters/ConsoleAppAdapter.php, src/App/Traits/WebAppTrait.php, src/Router/RouteDispatcher.php e src/Middleware/MiddlewareManager.php, insieme ai prerequisiti #536 e #537. Traccia prima l'avvio per fasi e i confini del runtime, quindi verifica che i test coprano l'avvio, il web, la console, il routing e il dispatch del ciclo di vita della risposta e che la semantica del ciclo di vita sia documentata senza aggiungere comportamenti specifici di debugbar.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

hooks runtime

Summary

Introduce a defined lifecycle hook surface across framework execution, built on top of the enhanced Hook/Event mechanism and the staged runtime structure introduced for boot and adapter runtime pipelines.

This ticket should establish the actual lifecycle contract that Quantum exposes for:

  • boot
  • web runtime
  • console runtime
  • route dispatch
  • response flow

Why

The prerequisite work provides the mechanism and structure:

  • #536 strengthens the Hook/Event foundation and bootstrap-time registration model
  • #537 introduces structured runtime pipelines for WebAppAdapter::start() and ConsoleAppAdapter::start()

This ticket should define where lifecycle hooks are emitted and which execution boundaries become part of the framework contract.

Goal

Define and wire the framework lifecycle hooks at meaningful execution boundaries, using the new staged boot/runtime structure rather than ad hoc method-level dispatch.

This ticket should establish which lifecycle points are officially exposed and where they are emitted.

Scope

This ticket should cover lifecycle hook points for:

  • boot stage boundaries
  • web runtime stage boundaries
  • console runtime stage boundaries
  • route dispatch boundaries
  • response send boundaries

It should not yet handle debugbar specifically. Debugbar integration should be implemented in a follow-up ticket once the lifecycle surface exists.

Proposed Direction

Boot lifecycle

Use stage-owned BEFORE / AFTER hook points for boot stages and dispatch them through the boot pipeline.

Web runtime lifecycle

Use stage-owned BEFORE / AFTER hook points for the new web runtime pipeline introduced in #537.

This should expose lifecycle points around stages such as:

  • preflight handling
  • route resolution
  • route-not-found handling
  • request preparation
  • request dispatch
  • response sending
  • request cleanup
Console runtime lifecycle

Use stage-owned BEFORE / AFTER hook points for the new console runtime pipeline introduced in #537.

This should expose lifecycle points around stages such as:

  • core command registration
  • app command registration
  • command validation
  • command execution
Route lifecycle

Add route-specific lifecycle hooks at the route dispatch layer, separate from pipeline stages.

This should cover meaningful boundaries such as:

  • before route dispatch
  • after route dispatch
Response lifecycle

Add response-specific lifecycle hooks around response sending.

This should cover meaningful boundaries such as:

  • before response send
  • after response send

Example Direction

Boot stage example:

final class LoadModulesStage implements BootStageInterface
{
    public const BEFORE = 'boot.modules.before';
    public const AFTER = 'boot.modules.after';

    public function process(AppContext $context): void
    {
        // existing logic
    }
}

Runtime stage example:

final class DispatchRequestStage implements RequestStageInterface
{
    public const BEFORE = 'web.dispatch.before';
    public const AFTER = 'web.dispatch.after';

    public function process(RequestContext $context): void
    {
        // cached response lookup, route dispatch, middleware execution
    }
}

Route lifecycle example:

event()->dispatch('route.dispatch.before', [
    'request' => $request,
    'matchedRoute' => $matched,
]);

$response = // existing dispatch logic

event()->dispatch('route.dispatch.after', [
    'request' => $request,
    'matchedRoute' => $matched,
    'response' => $response,
]);

Response lifecycle example:

event()->dispatch('response.send.before', [
    'request' => request(),
    'response' => $response,
]);

$response->send();

event()->dispatch('response.send.after', [
    'request' => request(),
    'response' => $response,
]);

Listener example:

event()->listen(DispatchRequestStage::AFTER, function (array $payload): void {
    $context = $payload['context'];
    // integration logic
});

Architectural Constraint

The lifecycle model introduced here must remain extensible for future event sources beyond the initial staged flow, including:

  • request/response extensions
  • route-level extensions
  • console-level extensions
  • user-defined business/domain events

The lifecycle contract should build on the staged structure, but must not be limited to stage-only use cases forever.

Acceptance Criteria

  • boot lifecycle hooks are defined and dispatched through boot stages
  • web runtime lifecycle hooks are defined and dispatched through runtime stages
  • console runtime lifecycle hooks are defined and dispatched through runtime stages
  • route lifecycle hooks are defined at the route dispatch layer
  • response lifecycle hooks are defined around response sending
  • lifecycle hook semantics are documented clearly enough for framework integrations and application code to rely on them
  • debugbar-specific behavior is not hardcoded as part of this ticket
  • tests cover lifecycle dispatch across boot, web runtime, console runtime, routing, and response flow

Notes

Relevant code:

  • src/App/BootPipeline.php
  • src/App/Adapters/WebAppAdapter.php
  • src/App/Adapters/ConsoleAppAdapter.php
  • src/App/Traits/WebAppTrait.php
  • src/Router/RouteDispatcher.php
  • src/Middleware/MiddlewareManager.php

Depends on:

  • #536
  • #537
Lingua principale
PHP
Stelle
36
Fork
22
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di quantum-php/framework

Tutte le issue di quantum-php/framework

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.