Refactor WebAppAdapter::start() and ConsoleAppAdapter::start() into structured runtime pipelines
还没有人认领这个 Issue。
评估
调研方向
从 src/App/Adapters/WebAppAdapter.php 和 src/App/Adapters/ConsoleAppAdapter.php 开始,然后跟踪相关 trait 和 src/App/BootPipeline.php。将当前的 start() 流程与 RouteDispatcher.php 和 MiddlewareManager.php 进行比较,以梳理运行时状态和职责。完成的标准是两个 adapter 都使用专用的运行时 pipeline 和 context 对象,同时保留所列出的 web 和 console 行为;根据需要更新测试。
由索引模型根据 Issue 内容生成。
描述
Summary
Refactor WebAppAdapter::start() and ConsoleAppAdapter::start() so runtime execution is no longer handled as flat sequences of loosely connected method calls.
Introduce structured runtime pipelines for web and console flows, similar in spirit to boot stages, so execution becomes explicit, extensible, and ready for future lifecycle hooks.
Why
The constructor already has a clear staged boot flow through BootPipeline, but runtime execution is still handled ad hoc.
In WebAppAdapter::start(), current responsibilities are mixed together in one method:
- preflight handling
- route resolution
- not found handling
- language loading
- debug info logging
- view cache setup
- cached response lookup
- route dispatch
- middleware execution
- response sending
- request cleanup
In ConsoleAppAdapter::start(), runtime execution is also flat:
- core command registration
- app command registration
- command validation
- command execution
This makes both runtime flows harder to reason about and leaves no clean structural boundaries for future lifecycle hooks.
Goal
Create proper runtime execution structures for both web and console adapters before introducing broader lifecycle hooks.
Runtime flow should become stage-based rather than remaining collections of ad hoc method calls.
Proposed Direction
Introduce dedicated runtime pipelines instead of reusing BootPipeline directly.
Suggested runtime structures:
RequestPipelineRequestContextConsolePipelineConsoleContext
These should carry evolving runtime state rather than relying on loose locals and inline control flow.
Suggested Web Runtime Stages
A reasonable first breakdown of the current web flow is:
HandlePreflightStageResolveRouteStageHandleRouteNotFoundStagePrepareRequestStageDispatchRequestStageSendResponseStageCleanupRequestStage
Notes:
PrepareRequestStageshould cover:- language loading
- debug info logging
- view cache setup
DispatchRequestStageshould cover:- cached response lookup
- route dispatch
- middleware execution
Suggested Console Runtime Stages
A reasonable first breakdown of the current console flow is:
RegisterCoreCommandsStageRegisterAppCommandsStageValidateCommandStageRunCommandStage
If needed, command registration can later be collapsed into a single preparation stage, but the first refactor should prioritize clarity.
Scope
This ticket is about refactoring runtime structure for both adapters.
It should not yet define the full lifecycle hook contract. That should come after runtime flow has proper structural boundaries.
Acceptance Criteria
WebAppAdapter::start()is refactored into a structured runtime pipelineConsoleAppAdapter::start()is refactored into a structured runtime pipeline- runtime state is carried through dedicated runtime context objects rather than loose local variables
- web runtime responsibilities such as language loading and view cache handling are preserved in the new structure
- console runtime responsibilities such as command registration, validation, and execution are preserved in the new structure
- the new runtime structures are suitable for later lifecycle hook integration
- tests are updated as needed
Notes
Relevant code:
src/App/Adapters/WebAppAdapter.phpsrc/App/Adapters/ConsoleAppAdapter.phpsrc/App/Traits/WebAppTrait.phpsrc/App/Traits/ConsoleAppTrait.phpsrc/Router/RouteDispatcher.phpsrc/Middleware/MiddlewareManager.phpsrc/App/BootPipeline.php
This ticket should be completed before introducing broader runtime lifecycle hooks.
- 主要语言
- PHP
- 星标
- 36
- 派生
- 22
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
quantum-php/framework 的其他 Issue
-
routing testing
难度 2/5 1-3 小时 新手友好度 76/100
quantum-php/framework#547 ·
-
view
难度 1/5 1 小时以内 新手友好度 75/100
quantum-php/framework#542 ·
-
enhancement http
难度 5/5 一周以上 新手友好度 35/100
quantum-php/framework#565 · 1 条评论 ·
-
components view
难度 5/5 一周以上 新手友好度 42/100
quantum-php/framework#551 ·
-
Add explicit @version special route token support for API major versioning within a single module未关闭routing
难度 5/5 一周以上 新手友好度 45/100
quantum-php/framework#550 ·
查看 quantum-php/framework 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1 小时以内 新手友好度 70/100
维护者通常 1 天内回复
-
customer-support needs-triage Platform(Default)
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
grokability/snipe-it#19767 ·
维护者通常 1 天内回复