selfphp/console
最新稳定版本:v1.0.0
Composer 安装命令:
composer require selfphp/console
包简介
Minimalistic PHP console component for simple command-line tools.
README 文档
README
🧩 A lightweight PHP console framework for simple CLI tools – with zero dependencies.
🚀 Features
- ✅ Register custom commands easily
- ✅ Automatic help command (
php bin/console help) - ✅ Clean PSR-4 structure
- ✅ Works on Windows, Linux, macOS
- ✅ No Symfony or external dependencies
📦 Installation
composer require selfphp/console
🛠 Usage
Create an entry file (e.g. bin/console):
#!/usr/bin/env php <?php require __DIR__ . '/../vendor/autoload.php'; use Selfphp\Console\ConsoleApp; use YourNamespace\Console\AuditCommand; use Selfphp\Console\Command\HelpCommand; $app = new ConsoleApp(); $app->register(new AuditCommand()); $app->register(new HelpCommand($app)); exit($app->run($argv));
Create a command:
namespace YourNamespace\Console; use Selfphp\Console\Contract\CommandInterface; class AuditCommand implements CommandInterface { public function getName(): string => 'audit'; public function getDescription(): string => 'Runs an audit'; public function run(array $args): int { echo "Audit running...\n"; return 0; } }
Run your CLI:
php bin/console audit
php bin/console help
🤝 Contributing
Feel free to submit issues, ideas or pull requests.
📄 License
MIT License © 2025 SELFPHP – Damir Enseleit
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-11