定制 noone-silent/phalcon-console 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

noone-silent/phalcon-console

Composer 安装命令:

composer require noone-silent/phalcon-console

包简介

Phalcon console framework for easier console command management and overview.

README 文档

README

The Phalcon Console package is a robust command-line interface (CLI) framework designed to simplify the creation and management of console Commands in Phalcon applications. Built with the Phalcon framework ecosystem in mind, this package provides developers with an elegant, attribute-driven approach to defining and executing command-line tasks with minimal boilerplate code.

Core Functionality

At its heart, the Phalcon Console package automates the discovery, registration, and execution of console Commands from your application's codebase. Rather than manually maintaining a command registry, the package uses PHP's reflection capabilities to dynamically scan specified directories for command classes, automatically extracting metadata about available Commands and their parameters through attributes and method signatures.

The package implements a command discovery system that scans PHP files in designated locations, parses class definitions to identify Commands, and extracts method-level metadata through the #[PhalconConsoleCommand] attribute. This allows developers to define new Commands by simply creating appropriately named classes with decorated methods. No complex configuration is required.

Installation

composer require noone-silent/phalcon-console

Configuration

For the discovery of Commands, add a list of all folders that you wish to scan for PHP-Classes. Modify your project composer.json and add the following configuration, adjusted to your needs. The bootstrap file is needed. There you instantiate the $di container used for the \Phalcon\Cli\Console class.

{
  "extras": {
    "phalcon-console": {
      "bootstrap": "path/to/your/cli/bootstrap.php",
      "locations": [
        ".",
        "src/",
        "app/",
        "cli/"
      ]
    }
  }
}

Now add the #[PhalconConsoleCommand] attribute to any method you want to be usable as command line command.

// Before

use Phalcon\Cli\Task;

class MyCliTask extends Task
{
    public function mainAction(string $date): void
    {
        // Do something
    }
    
    public function doSomethingAction(int $a, int $b = 2): void
    {
        // Do something
    }
}

// After

use Phalcon\Cli\Task;
use Phalcon\Console\PhalconConsoleCommand;

class MyCliTask extends Task
{
    #[PhalconConsoleCommand]
    public function mainAction(string $date): void
    {
        // Do something
    }
    #[PhalconConsoleCommand]
    public function doSomethingAction(int $a, int $b = 2): void
    {
        // Do something
    }
}

In the project root, where your vendor/ folder is located, you can run now the following script:

vendor/bin/phalcon-console

The output should have a listing looking like this:

mycli:
  mycli:main <date:string>
  mycli:dosomething <a:int> [b:int=2]

Here is an example image with a few commands:

example output

Parameters that are required are wrapped in < and >. Optional parameters are wrapped in [ and ].

Now you can execute a command:

vendor/bin/phalcon-console mycli:main date=2025-12-13

# or

vendor/bin/phalcon-console mycli:dosomething a=2 b=3

Advanced configuration

There are a few other options you can use. Below is the list with their default values.

{
  "extras": {
    "phalcon-console": {
      "locations": [],
      "bootstrap": "",
      "di": "di",
      "colored": true,
      "suffixes": [
        "Action",
        "Command",
        "Controller",
        "Task"
      ]
    }
  }
}

With the locations option, you define which folders need to be scanned. It uses the project root as a starting point.

The bootstrap option is needed, so you can set up your Phalcon application with all services that you need.

If you have named your DI different then $di, then you can set the name in the di option. Omit the dollar sign. If you named it $container then put container into the di setting.

The option colored is used to enable or disable colored output.

If your command has a suffix that you want to remove, you can add it to the suffixes option.

Testing

# start docker environment
docker compose up -d
# jump into the phalcon container
docker compose exec phalcon bash
# install composer requirements
composer install
# get a complete list of all available Commands
bin/phalcon-console
# execute a single command with some arguments
bin/phalcon-console dummy:say name=Phalcon

Roadmap

  • Caching (if needed)
  • Phalcon Module Support

noone-silent/phalcon-console 适用场景与选型建议

noone-silent/phalcon-console 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cli」 「console」 「command」 「Tasks」 「phalcon」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 noone-silent/phalcon-console 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 noone-silent/phalcon-console 我们能提供哪些服务?
定制开发 / 二次开发

基于 noone-silent/phalcon-console 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 43
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 29
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2025-12-14