Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Add a class-based component() helper for reusable view components

オープン
#551 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
42/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
php
領域
frontend

調査の方向性

まず src/View/Helpers/view.php と src/View/View.php を読んで、partial() と view のレンダリングがどのように動作するかを理解し、その後 HtmlAdapter.php と TwigAdapter.php のファイルを確認します。最小限のヘルパー、コンストラクター、render の契約、ネストしたレンダリングの動作、およびアクティブスタック上の循環検出を定義します。レンダリング、パラメーター、ネスト、再帰検出のテストで受け入れ基準がカバーされ、partial() が引き続き利用可能であれば完了です。

索引モデルが issue の本文から書いたものです。

説明

components view

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:

  1. resolve the component class
  2. instantiate it with the provided params
  3. call its render() method
  4. 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 A renders A
  • component A renders B, and B renders A

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.php
  • src/View/View.php
  • src/Renderer/Adapters/HtmlAdapter.php
  • src/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 はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quantum-php/framework のほかの issue

quantum-php/framework の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。