louzet/zenora
Composer 安装命令:
composer require louzet/zenora
包简介
A themed PHP CLI toolkit with attributes, task runner, progress bars, and widgets
README 文档
README
Zenora is a PHP 8.3+ toolkit to build rich CLIs quickly: attributes for commands/options, a configurable task runner with fiber-friendly spinner/progress bar, styled tables, interactive selects, and themed output.
Install
composer require louzet/zenora
Quick start
use Zenora\Attribute\Command; use Zenora\Attribute\Option; use Zenora\Context; use Zenora\Zenora; #[Command('app:hello', description: 'Say hello')] class HelloCommand { public function handle( Context $ctx, #[Option(shortcut: 'n')] string $name = 'World' ): void { $ctx->success("Hello $name!"); } } Zenora::forge() ->register(HelloCommand::class) ->ignite($argv);
Run:
php bin/console app:hello -n Alice php bin/console app:hello --help # auto help php bin/console --help # list commands
Parsing behavior
- Supports
--key=value,--key value,-k value, combined shorts-abc,-ab=c, and attached value-afoo. - Negative numbers after flags are allowed (
--threshold -5); for other values starting with-, use--to stop parsing or--key=value. - Use
--to stop flag parsing:cmd -- --literal -text. - Duplicate flags with conflicting values throw.
Services & hooks
$app = Zenith::forge() ->registerService(MyService::class, new MyService()) ->before(fn($name, $class) => /* log */) ->after(fn($name, $class, $result) => /* metrics */) ->register(MyCommand::class) ->ignite($argv);
Per-command services: registerServiceFor(CommandClass::class, id, service).
Task runner & progress
use Zenora\UI\ProgressBar; $ctx->configureTasks(tickMicroseconds: 50_000, progressWidth: 30, progressChars: ['filled' => '#', 'empty' => '.']); $ctx->work('Doing stuff...', function($pulse, ProgressBar $bar) { $bar->setTotal(3); foreach (range(1,3) as $i) { /* work */ $bar->advance()->setMessage("step $i"); $pulse(); } $bar->finish(); });
Use $ctx->progress() to show the bar without spinner.
Tables
use Zenora\UI\Table; $ctx->table( ['ID','Name','Notes'], [[1,'Alice','Long note that wraps...']], style: Table::STYLE_BOX, options: [ 'header_preset' => 'blue', 'alignments' => [0 => 'right', 2 => 'left'], 'formatter' => fn($row,$col,$val) => strtoupper($val), ] );
Headers default to the theme primary color; presets and custom ANSI codes are available.
Interactive select
Select uses raw mode; in non-TTY it falls back to the first option. POSIX terminals are supported; Windows raw-mode handling is not implemented yet (fallback to non-interactive).
Demo commands
Run in this repo:
php demo.php --help php demo.php demo:progress php demo.php demo:table php demo.php demo:args -fr 5 target php demo.php demo:service
Theme defaults
Colors come from the active theme (default CyberTheme). Table headers and progress bars will use theme primary unless overridden.
Known limitations
- Parsing is close to GNU but not identical; if a non-numeric value starts with
-, use--to terminate parsing or quote it. - Windows TTY support is not implemented; POSIX terminals recommended (Windows falls back to non-interactive select).
- No variadic args or custom value parsers yet.
Tests
composer test
Documentation
See docs/ for more focused examples (tasks, tables, progress, services, hooks, and interactive widgets). You can run them locally to capture screenshots.
louzet/zenora 适用场景与选型建议
louzet/zenora 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cli」 「command」 「attributes」 「terminal」 「progress」 「table」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 louzet/zenora 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 louzet/zenora 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 louzet/zenora 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Wrapper for exec and it's results
Symfony bundle to monitor and execute commands
Shell command module for PHP.
Library with classes to help you do batch.
A library that allows you to easily use the PHP-VCR library in your PHPUnit tests.
This Package provides some usefully console features like the attribute syntax for arguments and options, validation, auto ask and casting.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-22