Add a class-based component() helper for reusable view components
まだ誰も着手していません。
評価
調査の方向性
まず src/View/Helpers/view.php と src/View/View.php を読んで、partial() と view のレンダリングがどのように動作するかを理解し、その後 HtmlAdapter.php と TwigAdapter.php のファイルを確認します。最小限のヘルパー、コンストラクター、render の契約、ネストしたレンダリングの動作、およびアクティブスタック上の循環検出を定義します。レンダリング、パラメーター、ネスト、再帰検出のテストで受け入れ基準がカバーされ、partial() が引き続き利用可能であれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
Add a first version of view components to Quantum through a class-based helper:
component('ComponentName', array $params = [])
This should provide a more structured alternative to partial() for reusable view fragments with their own class logic and rendering behavior.
Why
Quantum already has:
partial()
which is useful for simple reusable view fragments, but it is only a direct partial render/include mechanism.
A component system should support a more sophisticated approach where a reusable view fragment is backed by a class that can:
- accept params
- prepare internal state in
__construct() - render its own partial through
render()
This is the first step toward a broader component model inspired by frameworks such as Vue, React, Angular, Laravel Blade components, and similar PHP approaches, without introducing tag parsing yet.
Goal
Introduce a minimal component runtime for Quantum that allows views to render reusable class-backed components through a helper call.
Proposed Direction
Add a helper such as:
component('Alert', [
'type' => 'error',
'message' => 'Something went wrong',
]);
The helper should:
- resolve the component class
- instantiate it with the provided params
- call its
render()method - return the rendered string output
First version scope
This first version should stay intentionally minimal.
It should support:
- a class-based component model
- constructor-based param handling
- string rendering through
render()
It should not yet include:
- XHTML parsing
<x-...>tag syntax- slot support
- anonymous/file-only components
- advanced component templating syntax
Those can come later.
Component contract
The first version should keep the component API small.
A likely minimal shape is:
__construct(array $params = [])render(): string
This allows the component class to normalize params and render its own partial or output.
Rendering behavior
A component should typically render through the existing view/partial rendering system, rather than bypassing it.
That keeps the feature aligned with Quantum’s current view architecture and allows the helper to work with the existing rendering model.
Nesting behavior
Components should be allowed to render other components.
That means:
- component nesting is supported
- normal repeated component usage is allowed
However, circular component rendering must be detected and blocked.
Examples that must fail:
- component
ArendersA - component
ArendersB, andBrendersA
This first version should include circular-render detection through an active render stack.
It does not need a configurable max-depth setting in the first version.
Why this version first
The long-term direction may include an XHTML renderer that parses tags like:
<x-alert><x-post-card>
But that should be treated as a later version.
The first version should establish the component class contract and helper-based runtime first, so future XHTML parsing can build on the same component model instead of introducing a second one.
Acceptance Criteria
- a global/helper-level
component()API exists - the helper resolves and instantiates component classes
- params can be passed into component constructors as an array
- component classes return rendered output through
render(): string - components can render other components
- circular component rendering is detected and blocked
partial()remains available for simpler use cases- tests cover basic rendering, param passing, nesting, and circular recursion detection
Notes
Relevant code:
src/View/Helpers/view.phpsrc/View/View.phpsrc/Renderer/Adapters/HtmlAdapter.phpsrc/Renderer/Adapters/TwigAdapter.php
This ticket is the minimal component-runtime foundation and should come before any XHTML or <x-...> parsing work.
- 主要言語
- PHP
- スター
- 36
- フォーク
- 22
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 35/100
quantum-php/framework#565 · コメント 1 件 ·
-
Add explicit @version special route token support for API major versioning within a single moduleオープンrouting
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
quantum-php/framework#550 ·
-
lang routing
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
quantum-php/framework#549 ·
quantum-php/framework の issue をすべて見る
似ている issue
-
0. Needs triage 35-feedback bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
unraid/webgui#2781 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
symfony/maker-bundle#1841 ·
メンテナーはふだん 1 日以内に返信
-
bug complete-verify
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
MagnaCapax/PMSS#998 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信
-
Bug (unconfirmed)
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
FreshRSS/FreshRSS#9394 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信