bear8421/command-line-tool
Composer 安装命令:
composer create-project bear8421/command-line-tool
包简介
Base Command Line Tool use Silly CLI micro-framework based on Symfony Console
README 文档
README
Start Project Command Line Tool use PHP with Silly CLI micro-framework based on Symfony Console
Donate Me
Buy me a coffee: https://paypal.me/nguyenanhung
Summary
| Key | Value |
|---|---|
| Project | Command Line Tool |
| Framework | Silly CLI micro-framework |
| GitHub | https://github.com/bear8421/command-line-tool |
| Packagist | https://packagist.org/packages/bear8421/command-line-tool |
Install the Application
Run this command from the directory in which you want to install your new CLI micro-framework application.
composer create-project bear8421/command-line-tool [my-app-name]
or
php composer.phar create-project bear8421/command-line-tool [my-app-name]
Replace [my-app-name] with the desired directory name for your new application.
Usage
Create TestCommand in namespace Bear\App\Command
class TestCommand { public function __invoke($name, $upper, OutputInterface $output) { if ($name) { $text = 'Hello, Iam ' . $name; $output->writeln("Bear"); } else { $text = 'Hello, Iam. BEAR'; } if ($upper) { $text = strtoupper($text); } $output->writeln($text); } }
And declare Command in Bear in bear file in root folder
#!/usr/bin/env php <?php if (php_sapi_name() !== 'cli') { exit; } // Register Application Space define('BEAR', $_SERVER['BEAR_ENV'] ?? 'production'); // Includes Composer Vendor Packages require_once __DIR__ . '/vendor/autoload.php'; use Silly\Edition\PhpDi\Application; use Bear\App\Command\TestCommand; $app = new Application(); $app->setName(ENV_APP_NAME); // Routes list Command $app->command(parseExpressionOptions('greet', [ 'u|upper', 'r|randomFaker' ]), TestCommand::class)->descriptions(TestCommand::$desc, TestCommand::$optionsInfo); try { $app->run(); } catch (Exception $e) { echo $e->getMessage(); }
Running the application is the same as running any other Symfony Console application:
$ php bear greet
Hello
$ php bear greet vietnam --upper
HELLO JOHN
$ php bear greet --upper vietnam
HELLO JOHN
Silly\Application extends Symfony\Console\Application and can be used wherever Symfony's Application can.
Binaries Bash Setup
Setup in to .bash_profile or .zshrc
export PATH="/your/path/bin:$PATH"
Reload Bash session
source ~/.bash_profile
hoặc
source ~/.zshrc
Use with Binaries
bear greet --upper vietnam
Documentation
Also see Official Document here: https://github.com/bear8421/command-line-tool/tree/main/docs
Contact
If any question & request, please contact following information
| Name | GitHub | ||
|---|---|---|---|
| Hung Nguyen | dev@nguyenanhung.com | @nguyenanhung | @nguyenanhung |
From Hanoi with Love ❤️
bear8421/command-line-tool 适用场景与选型建议
bear8421/command-line-tool 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 09 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bear8421/command-line-tool 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bear8421/command-line-tool 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-21