attreid /
Nette Cli 控制台带有网页界面
1.0.1
2023-03-15 08:18 UTC
Requires
- php: >= 8.1
- nette/application: ^3.1
- nette/di: ^3.0
- tracy/tracy: ~2.4
Requires (Dev)
- nette/tester: ^2.3
This package is auto-updated.
Last update: 2024-09-15 11:36:53 UTC
README
在 config.neon 中的设置
extensions: console: Atrreid\Console\DI\ConsoleExtension
可用设置
console: prefix: cli collections: - ClassWithCommands
添加路由
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 }
命令
class ClassWithCommands extends CommandCollection { /** * Comment, show in help * @param string $variable comment */ public function command(string $variable): void { $this->printLine('Some info'); // php code } }
运行
在控制台中运行
php index.php ClassWithCommands:command /variable=value
或在浏览器中运行(Tracy 开启)
http://domain/cli/ClassWithCommands/command?variable=value