PHPackages                             mix/cli-skeleton - 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. mix/cli-skeleton

ActiveProject

mix/cli-skeleton
================

CLI development skeleton

v3.0.34(3y ago)02881Apache-2.0PHP

Since Aug 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mix-php/cli-skeleton)[ Packagist](https://packagist.org/packages/mix/cli-skeleton)[ Docs](https://openmix.org/mix-php)[ RSS](/packages/mix-cli-skeleton/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (7)Versions (14)Used By (0)

CLI development skeleton
========================

[](#cli-development-skeleton)

帮助你快速搭建 CLI 项目骨架，并指导你如何使用该骨架的细节，骨架默认开启了 SQL、Redis 日志，压测前请先关闭 `.env` 的 `APP_DEBUG`

安装
--

[](#安装)

```
composer create-project --prefer-dist mix/cli-skeleton cli

```

快速开始
----

[](#快速开始)

使用 `composer` 执行命令

```
composer run-script --timeout=0 cli:clearcache

```

执行脚本
----

[](#执行脚本)

- `composer run-script` 命令中的 `--timeout=0` 参数是防止 composer [执行超时](https://getcomposer.org/doc/06-config.md#process-timeout)
- `composer.json` 定义了命令执行脚本，对应上面的执行命令

```
"scripts": {
    "cli:clearcache": "php bin/cli.php clearcache"
}
```

当然也可以直接下面这样启动，效果是一样的，但是 `scripts` 能帮你记录到底有哪些可用的命令，同时在IDE中调试更加方便。

```
php bin/cli.php clearcache

```

编写一个 CLI 程序
-----------

[](#编写一个-cli-程序)

首先我们在 `bin/cli.php` 入口文件中增加一个命令

- 如何配置命令：[mix/cli](https://github.com/mix-php/cli#readme)

```
Cli::setName('app')->setVersion('0.0.0-alpha');
$cmds = [
    new Mix\Cli\Command([
        'name' => 'clearcache',
        'short' => 'Clear cache',
        'options' => [
            new Mix\Cli\Option([
                'names' => ['k', 'key'],
                'usage' => 'Key name'
            ]),
        ],
        'run' => new App\Command\ClearCache(),
    ])
];
Cli::addCommand(...$cmds)->run();
```

查看命令帮助，检查配置是否正确

```
$ php bin/cli.php
Usage: bin/cli.php [OPTIONS] COMMAND [ARG...]

Commands:
  clearcache    Clear cache

Global Options:
  -h, --help    Print usage
  -v, --version Print version information

Run 'bin/cli.php COMMAND --help' for more information on a command.

Developed with Mix PHP framework. (openmix.org/mix-php)

```

执行 `clearcache` 命令

```
$ php bin/cli.php clearcache

```

使用容器中的对象
--------

[](#使用容器中的对象)

容器采用了一个简单的单例模式，你可以修改为更加适合自己的方式。

- 数据库：[mix/database](https://github.com/mix-php/database#readme)

```
DB::instance()

```

- Redis：[mix/redis](https://github.com/mix-php/redis#readme)

```
RDS::instance()

```

- 日志：[monolog/monolog](https://seldaek.github.io/monolog/doc/01-usage.html)

```
Logger::instance()

```

- 配置：[hassankhan/config](https://github.com/hassankhan/config#getting-values)

```
Config::instance()

```

License
-------

[](#license)

Apache License Version 2.0,

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.5% 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 ~51 days

Recently: every ~83 days

Total

13

Last Release

1126d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16074765?v=4)[LIU JIAN](/maintainers/onanying)[@onanying](https://github.com/onanying)

---

Top Contributors

[![onanying](https://avatars.githubusercontent.com/u/16074765?v=4)](https://github.com/onanying "onanying (19 commits)")[![cexll](https://avatars.githubusercontent.com/u/26520956?v=4)](https://github.com/cexll "cexll (1 commits)")[![quhaowk](https://avatars.githubusercontent.com/u/42995157?v=4)](https://github.com/quhaowk "quhaowk (1 commits)")

### Embed Badge

![Health badge](/badges/mix-cli-skeleton/health.svg)

```
[![Health](https://phpackages.com/badges/mix-cli-skeleton/health.svg)](https://phpackages.com/packages/mix-cli-skeleton)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.1k23.1k9](/packages/tempest-framework)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[doppar/framework

The Doppar Framework

366.7k8](/packages/doppar-framework)[lion/bundle

Lion-framework configuration and initialization package

122.2k1](/packages/lion-bundle)

PHPackages © 2026

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