PHPackages                             rice/ctl - 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. rice/ctl

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

rice/ctl
========

php control

v1.1.5(2y ago)240Apache-2.0PHP

Since Dec 29Pushed 2y agoCompare

[ Source](https://github.com/rice-code/ctl)[ Packagist](https://packagist.org/packages/rice/ctl)[ RSS](/packages/rice-ctl/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

[![License](https://camo.githubusercontent.com/b3dd5777bf0d89dc72a2045cbf476c7bcdab389bd0ad40aeb339da333c3a2265/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322d3445423142412e737667)](https://www.apache.org/licenses/LICENSE-2.0.html)[![github star](https://camo.githubusercontent.com/0dec1e95ec80b1802002b1f1964eca37af60b7937802fd6f08862279b430c8f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f726963652d636f64652f63746c2e737667)](https://camo.githubusercontent.com/0dec1e95ec80b1802002b1f1964eca37af60b7937802fd6f08862279b430c8f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f726963652d636f64652f63746c2e737667)[![github fork](https://camo.githubusercontent.com/1b21b338d5d05d0a7403ad9b4f1dd2e07cdb05acaf8152cfc29c2f2f1d49f182/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f726963652d636f64652f63746c2e737667)](https://camo.githubusercontent.com/1b21b338d5d05d0a7403ad9b4f1dd2e07cdb05acaf8152cfc29c2f2f1d49f182/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f726963652d636f64652f63746c2e737667)[![.github/workflows/ci.yml](https://github.com/rice-code/ctl/actions/workflows/ci.yml/badge.svg)](https://github.com/rice-code/ctl/actions/workflows/ci.yml)

php 命令行 （php control）
---------------------

[](#php-命令行-php-control)

### 安装

[](#安装)

```
composer require rice/ctl
```

### 功能点

[](#功能点)

1. setting, getting 注释生成命令 [锚点](#%E8%AE%BF%E9%97%AE%E5%99%A8%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90%E6%B3%A8%E9%87%8A)
2. json 转 class 对象命令 [锚点](#json-%E8%BD%AC-class-%E5%AF%B9%E8%B1%A1)

### 访问器自动生成注释

[](#访问器自动生成注释)

以这个 `tests\Support\Annotation\Cat.php` 文件为例，我们使用了 `Accessor` 这个 `trait`。所以会 存在 `setxxx()` 和 `getxxx()`，但是这里面会造成实例化类后调用没有相关的函数提示。为了解决这个问题，可以 使用 `php ctl.php rice:accessor xxx\tests\Support\Annotation\Cat.php` 去执行自动生成注释。

> 只会生成protected 属性的注释，如果属性没有指定类型，那么会查看注释是否有 @var 指定相关类型，有的 话自动获取

生成前：

```
class Cat
{
    use AutoFillProperties;
    use Accessor;

    /**
     * 眼睛.
     *
     * @return $this
     *
     * @throws \Exception
     *
     * @var string
     * @Param $class
     */
    protected $eyes;

    /**
     * @var S
     */
    protected $speak;
}
```

生成后：

```
/**
 * Class Cat.
 * @method self     setEyes(string $value)
 * @method string   getEyes()
 * @method self     setSpeak(S $value)
 * @method S        getSpeak()
 */
class Cat
{
    use AutoFillProperties;
    use Accessor;

    /**
     * @var string
     * @Param $class
     */
    protected $eyes;

    /**
     * @var S
     */
    protected $speak;
}
```

#### tips：推荐属性是对象时不要使用长链式调用

[](#tips推荐属性是对象时不要使用长链式调用)

##### bad

[](#bad)

```
$cat = new \Tests\Entity\Cat();
$cat->getSpeak()->text();
```

##### better

[](#better)

Cat重写一个方法

```
public function getSpeakText(): string
{
    return $this->getSpeak()->text();
}

$cat->getSpeakText();
```

这样子做的好处是提高内聚性，虽然直接链式调用会方便使用，但是出现链式的一个 环节要修改名称的时候，如果多个地方都有使用到，那么修改起来就会存在多个地方。 重写方法后，统一使用 `Cat` 类的 `getSpeakText` 方法。需要修改时，就只 改动 `Cat` 类就行了，降低出错成本。

### json 转 class 对象

[](#json-转-class-对象)

`_class_name`: 类名称 `_type`: 类的类型（DTO 或 Entity） `_namespace`: 类的命名空间

调用 `php generator.php rice:json_to_class xxx\basic\tests\Generate\tsconfig.json xxx\basic\tests\Generate\`

第一个参数是输入的 `json` 文件路径，第二个参数是生成文件所在的目录

```
{
  "_class_name": "Test",
  "_type": "Entity",
  "_namespace": "Tests\\Generate",
  "data": [
    {
      "insights": {
        "data": [
          {
            "name": "post_impressions",
            "period": "lifetime",
            "values": [
              {
                "value": 614
              }
            ],
            "title": "Lifetime Post Total Impressions",
            "description": "Lifetime: The number of times your Page's post entered a person's screen. Posts include statuses, photos, links, videos and more. (Total Count)"
          }
        ],
        "paging": {
          "previous": "xxxxxxxxxxxxxxx",
          "next": "yyyyyyyyyyyyyyy"
        }
      },
      "created_time": "2021-10-13T16:11:55+0000",
      "message": "Very important message"
    }
  ],
  "paging": {
    "cursors": {
      "before": "xxxxxxxxxxxxxxx",
      "after": "yyyyyyyyyyyyyyy"
    },
    "next": "zzzzzzzzzz"
  }
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~29 days

Recently: every ~40 days

Total

8

Last Release

1027d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2cf1bfb9f7b6b44ecde2f6156de38d46f2486b36651882e97eac68e81043e883?d=identicon)[dmf-code](/maintainers/dmf-code)

---

Top Contributors

[![dmf-code](https://avatars.githubusercontent.com/u/22268578?v=4)](https://github.com/dmf-code "dmf-code (30 commits)")

### Embed Badge

![Health badge](/badges/rice-ctl/health.svg)

```
[![Health](https://phpackages.com/badges/rice-ctl/health.svg)](https://phpackages.com/packages/rice-ctl)
```

###  Alternatives

[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[php-soap/wsdl

Deals with WSDLs

173.5M12](/packages/php-soap-wsdl)[overtrue/php-opencc

中文简繁转换，支持词汇级别的转换、异体字转换和地区习惯用词转换（中国大陆、台湾、香港、日本新字体）。基于 \[BYVoid/OpenCC\](https://github.com/BYVoid/OpenCC) 数据实现。

12130.7k](/packages/overtrue-php-opencc)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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