moonspot/component
Composer 安装命令:
composer require moonspot/component
包简介
Library for creating HTML components in PHP
README 文档
README
A library for creating HTML components in PHP.
Creating consitent HTML components is important for good user experience. This library aims to make creating those components easier. It is the result of work I have done for years on different projects. A prime reason for this library and some of the techniques it uses is performance.
Example
Text Input
use Moonspot\Component\ComponentAbstract; class TextInput extends ComponentAbstract { // Define the attributes for the component as public properties // id and class are defined in the parent class for all components. public string $type = 'text'; public string $name = ''; public bool $required = false; public int|null $minlength = null; public int|null $maxlength = null; public int|null $size = null; // For other settings, define them as protected properties protected string $label = ''; // function where the markup is defined public function markup() { ?> <label for="<?=htmlspecialchars($this->id)?>"><?=htmlspecialchars($this->label)?></label><br> <input <?=$this->attributes()?> /> <?php } // An inline style or a link tag to a css file can be used here. // Either way, it will only be included once in the output. There // is also a similar function named "script" for loading script tags. public static function css() { ?> <style> input[type=text] { font-size: 14px; } </style> <?php } } TextInput::render(attributes: [ 'id' => 'myinput1' ]); TextInput::render(attributes: [ 'id' => 'myinput2' ]);
Output:
<style> input[type=text] { font-size: 14px; } </style> <input id="myinput1" type="text" /> <input id="myinput2" type="text" />
moonspot/component 适用场景与选型建议
moonspot/component 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 109 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 moonspot/component 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 moonspot/component 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 109
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2025-06-16