PHPackages                             topphp/component-builder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. topphp/component-builder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

topphp/component-builder
========================

组件生成器

046PHPCI failing

Since Mar 12Pushed 6y ago1 watchersCompare

[ Source](https://github.com/topphp/component-builder)[ Packagist](https://packagist.org/packages/topphp/component-builder)[ RSS](/packages/topphp-component-builder/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

component-builder
=================

[](#component-builder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ae0f52c74a61961e9db29f01772b38ba685e4a7834a3d52453f28b289d9029e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f707068702f636f6d706f6e656e742d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/topphp/component-builder)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/5d3aefa15bde2efe2eed14c4d2bfc5051244102a20a0ea27b8c7006874dbbb52/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f746f707068702f636f6d706f6e656e742d6275696c6465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/topphp/component-builder)[![Coverage Status](https://camo.githubusercontent.com/096a8cda4a12a912d5175178d793cbc6d446f774437b9bd332551c252cf65b6e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f746f707068702f636f6d706f6e656e742d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/topphp/component-builder/code-structure)[![Quality Score](https://camo.githubusercontent.com/d0907b3f978036ba7d9d25d9e7e6cb309b3d35b533a1263b4f1ec070c9e39a9c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f746f707068702f636f6d706f6e656e742d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/topphp/component-builder)[![Total Downloads](https://camo.githubusercontent.com/005f716166c16d1e3c68f324454da4b8e9beb429be5097bd10b75455fb02117d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f707068702f636f6d706f6e656e742d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/topphp/component-builder)

前言 为了让开发者更好的为 topphp 开发组件，我们提供了本指南用于指导开发者进行组件开发，在阅读本指南前，需要您对 topphp和thinkphp 的文档进行仔细的阅读。

为什么要开发组件
========

[](#为什么要开发组件)

在 PHP-FPM 架构下的开发，通常在我们需要借助第三方库来解决我们的需求时，都会通过 Composer 来直接引入一个对应的组件，但是有时候第三方库并不能满足我们的需求时,会自己进行一个组件的封装.而且topphp可以在swoole环境下持久化运行,且支持协程,导致了第三方组件会存在一些使用上的问题. 阅读本指南会教会你如何开发一个属于自己的topphp组件.

组件开发的环境及准备工作
============

[](#组件开发的环境及准备工作)

##### 1.安装骨架项目(topphp/topphp-skeleton):

[](#1安装骨架项目topphptopphp-skeleton)

```
git clone https://github.com/topphp/topphp-skeleton.git
```

##### 2. 同级目录下添加`topphp`文件夹

[](#2-同级目录下添加topphp文件夹)

##### 3.进入`topphp文件夹`,并通过组件创建器(topphp/component-builder)进行组件创建:

[](#3进入topphp文件夹并通过组件创建器topphpcomponent-builder进行组件创建)

```
# 运行以下命令
$ cd topphp
$ composer create-project topphp/component-builder=dev-master 你的组件名字

composer create-project topphp/component-builder=dev-master topphp-testing
Installing topphp/component-builder (dev-master 63957ce7c3e9e8425c280c0fa4135e847a6d5ec3)
- Installing topphp/component-builder (dev-master 63957ce): Cloning 63957ce7c3 from cache
Created project in topphp-testing
> Topphp\Install\Shell::init
请对组件进行配置
请输入你的组件名称(topphp/demo):topphp/topphp-testing
填写你的组件描述:单元测试组件
请设置你的软件许可证(MIT):
请填写应用命名空间 (Topphp\TopphpTesting):
需要安装 topthink/framework 组件吗? [n]:y
正在删除安装脚本命名空间...
正在删除安装脚本相关composer配置...
删除安装脚本目录
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 29 installs, 0 updates, 0 removals
- Installing sebastian/version (2.0.1): Loading from cache
- Installing sebastian/resource-operations (2.0.1): Loading from cache
- Installing sebastian/recursion-context (3.0.0): Loading from cache
- Installing sebastian/object-reflector (1.1.1): Loading from cache
- Installing sebastian/object-enumerator (3.0.3): Loading from cache
- Installing sebastian/global-state (2.0.0): Loading from cache
- Installing sebastian/exporter (3.1.2): Loading from cache
- Installing sebastian/environment (4.2.3): Loading from cache
- Installing sebastian/diff (3.0.2): Loading from cache
- Installing sebastian/comparator (3.0.2): Loading from cache
- Installing phpunit/php-timer (2.1.2): Loading from cache
- Installing phpunit/php-text-template (1.2.1): Loading from cache
- Installing phpunit/php-file-iterator (2.0.2): Loading from cache
- Installing theseer/tokenizer (1.1.3): Loading from cache
- Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache
- Installing phpunit/php-token-stream (3.1.1): Loading from cache
- Installing phpunit/php-code-coverage (6.1.4): Loading from cache
- Installing doctrine/instantiator (1.3.0): Loading from cache
- Installing symfony/polyfill-ctype (v1.13.1): Loading from cache
- Installing webmozart/assert (1.6.0): Loading from cache
- Installing phpdocumentor/reflection-common (2.0.0): Loading from cache
- Installing phpdocumentor/type-resolver (1.0.1): Loading from cache
- Installing phpdocumentor/reflection-docblock (5.0.0): Loading from cache
- Installing phpspec/prophecy (v1.10.2): Loading from cache
- Installing phar-io/version (2.0.1): Loading from cache
- Installing phar-io/manifest (1.0.3): Loading from cache
- Installing myclabs/deep-copy (1.9.5): Loading from cache
- Installing phpunit/phpunit (7.5.20): Loading from cache
- Installing squizlabs/php_codesniffer (3.5.4): Loading from cache
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.6.0)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0)
phpunit/phpunit suggests installing ext-xdebug (*)
Writing lock file
Generating autoload files
Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]? Y
```

##### 4.这样做的目的是为了让 `topphp-skeleton` 项目可以直接通过 `path` 的形式，让 Composer 直接通过 `topphp` 文件夹内的项目作为依赖项被加载到 `topphp-skelton` 项目的 `vendor` 目录中，我们对 `topphp-skelton` 内的 `composer.json` 文件增加一个 repositories 项，如下：

[](#4这样做的目的是为了让-topphp-skeleton-项目可以直接通过-path-的形式让-composer-直接通过-topphp-文件夹内的项目作为依赖项被加载到-topphp-skelton-项目的-vendor-目录中我们对-topphp-skelton-内的-composerjson-文件增加一个-repositories-项如下)

```
{
    "repositories": {
        "hyperf": {
            "type": "path",
            "url": "../topphp/*"
        },
        "packagist": {
            "type": "composer",
            "url": "https://mirrors.aliyun.com/composer"
        }
    }
}
```

##### 5.然后删除 `topphp-skeleton` 项目内的 `composer.lock` 文件和 `vendor` 目录，再执行 `composer require 你刚刚安装的组件=dev-master`,或者直接在 `composer.json` 增加如下代码:

[](#5然后删除-topphp-skeleton-项目内的-composerlock-文件和-vendor-目录再执行-composer-require-你刚刚安装的组件dev-master或者直接在-composerjson-增加如下代码)

```
{
   "require":{
      "你的组件名字": "dev-master"
  }
}
```

> 然后就可以对组件进行开发了.

#### 注意

[](#注意)

> 交互输入必须使用英文半角输入法,否则会出现字符确实.

现代的PHP组件都使用语义版本方案(), 版本号由三个点(.)分数字组成(例如:1.13.2).第一个数字是主版本号,如果PHP组件更新破坏了向后兼容性,会提升主版本号. 第二个数字是次版本号,如果PHP组件小幅更新了功能,而且没有破坏向后兼容性,会提升次版本号. 第三个数字(即最后一个数字)是修订版本号,如果PHP组件修正了向后兼容的缺陷,会提升修订版本号.

Structure
---------

[](#structure)

> 组件结构

```
bin/
build/
docs/
config/
src/
tests/
vendor/

```

Install
-------

[](#install)

Via Composer

```
$ composer create-project topphp/component-builder 你的组件名称
```

Usage
-----

[](#usage)

```
$skeleton = new topphp\componentBuilder();
echo $skeleton->echoPhrase('Hello, TOPPHP!');
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [topphp](https://github.com/topphp)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/3774ddafd6cc1dbff3db41386611fac2236c095e12c9e99f1717da35ad792087?d=identicon)[topphp](/maintainers/topphp)

---

Top Contributors

[![go-sleep](https://avatars.githubusercontent.com/u/100214298?v=4)](https://github.com/go-sleep "go-sleep (32 commits)")

### Embed Badge

![Health badge](/badges/topphp-component-builder/health.svg)

```
[![Health](https://phpackages.com/badges/topphp-component-builder/health.svg)](https://phpackages.com/packages/topphp-component-builder)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
