initphp / console
这是一个简单的辅助库,允许您使用PHP编写控制台/命令行应用程序。
2.0
2023-12-16 15:56 UTC
Requires
- php: >=7.2
This package is auto-updated.
Last update: 2024-09-16 17:32:48 UTC
README
这是一个简单的辅助库,允许您使用PHP编写控制台/命令行应用程序。
需求
- PHP 7.2 或更高版本
安装
composer require initphp/console
用法
#!/usr/bin/env php <?php require_once __DIR__ . '/../vendor/autoload.php'; use \InitPHP\Console\{Application, Input, Output}; $console = new Application("My Console Application", '1.0'); // Register commands ... // hello -name=John $console->register('hello', function (Input $input, Output $output) { if ($input->hasArgument('name')) { $output->writeln('Hello {name}', [ 'name' => $input->getArgument('name') ]); } else { $output->writeln('Hello World!'); } }, 'Says hello.'); $console->run();
php console.php list
致谢
许可证
版权所有 © 2022 MIT 许可证