attreid/console
最新稳定版本:1.0.2
Composer 安装命令:
composer require attreid/console
包简介
Nette Cli console with web interface
README 文档
README
Requirements: PHP 8.4+
Settings in config.neon
extensions: console: Atrreid\Console\DI\ConsoleExtension
available settings
console: prefix: cli collections: - ClassWithCommands
Add route
class RouterFactory public function __construct(private readonly \Attreid\Console\Routing\RouterFactory $consoleRouterFactory) { } public function createRouter(): RouteList { $router = new RouteList; $this->consoleRouterFactory->createRoutes($router); // other routes }
Commands
class ClassWithCommands extends CommandCollection { /** * Comment, show in help * @param string $variable comment */ public function command(string $variable): void { $this->printLine('Some info'); // php code } }
Run
Run in console
php index.php ClassWithCommands:command /variable=value
or in browser with Tracy on
http://domain/cli/ClassWithCommands/command?variable=value
Development / Docker
Build and run the PHP 8.4 CLI container:
docker compose up -d docker compose exec php composer install docker compose exec php composer test docker compose exec php php index.php ClassWithCommands:command /variable=value
One-off run (e.g. install and test without keeping container):
docker compose run --rm php composer install
docker compose run --rm php composer test
Tests
- In Docker (recommended):
docker compose run --rm php composer test
docker compose run --rm php composer test:coverage
- Locally (if you have PHP 8.4 + Composer):
- Run tests:
composer test - Run tests with coverage:
composer test:coverage(generatescoverage.html)
- Run tests:
统计信息
- 总下载量: 37
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-10