simsoft/console
Composer 安装命令:
composer require simsoft/console
包简介
A lightweight, Laravel-inspired wrapper for Symfony Console — build PHP CLI commands with less boilerplate.
关键字:
README 文档
README
A lightweight, Laravel-inspired wrapper for Symfony Console — built PHP CLI commands with less boilerplate.
Requirements
- PHP 8.2+
- Symfony Console ^7.2 || ^8.0
- Symfony Lock ^7.2 || ^8.0
- dragonmantank/cron-expression ^3.4
- psr/container ^2.0
Installation
composer require simsoft/console
Quick Start
<?php declare(strict_types=1); require "vendor/autoload.php"; use App\Commands\HelloWorldCommand; use Simsoft\Console\Application; $status = Application::make('My App', '1.0') ->withCommands([ HelloWorldCommand::class, ]) ->run(); exit($status);
<?php declare(strict_types=1); namespace App\Commands; use Simsoft\Console\Command; class HelloWorldCommand extends Command { static string $name = 'screen:welcome'; static string $description = 'Display a welcome message'; protected function handle(): void { $this->info('Hello World'); } }
php console screen:welcome
# Output: Hello World
Documentation
| Topic | Description |
|---|---|
| Creating Commands | Class-based and closure commands |
| Console Input | Arguments, options, and retrieval methods |
| Writing Output | Formatted messages, timestamps, newlines |
| Helpers | Question, table, progress bar, progress indicator, tree |
| Calling Commands | Call from other commands or application code |
| Command Locking | Prevent parallel execution |
| Dependency Injection | PSR-11 container, resolve(), constructor injection |
| Task Scheduling | Cron scheduling, hooks, overlap, output capture, pings |
| Logging | PSR-3 logging via DI container |
| Traits | DateRangeOption, DateOption, FileOption, DryRun, Retry, OutputFormat, etc. |
API Quick Reference
Application
| Method | Description |
|---|---|
Application::make($name, $version) |
Create instance |
->withContainer(ContainerInterface) |
Set PSR-11 container |
->withCommands(array $classes) |
Register commands |
->withScheduler(Closure) |
Configure scheduler |
->run() |
Run the application |
Application::call($name, $input, $silently) |
Execute programmatically |
Command
| Method | Description |
|---|---|
$this->argument($name, $default) |
Get argument |
$this->option($name, $default) |
Get option |
$this->info($msg) / error() / comment() / line() |
Output |
$this->ask() / secret() / confirm() / choice() |
Prompts |
$this->table($headers, $rows) |
Render table |
$this->withProgressBar($data, $callback) |
Progress bar |
$this->createProgressBar($max) |
Manual progress bar |
$this->createProgressIndicator() |
Indeterminate progress spinner |
$this->tree($root, $values) |
Render tree structure |
$this->call($name, $input) / callSilently() |
Call commands |
$this->resolve($id) / hasService($id) |
DI container access |
Comparison with Alternatives
| Simsoft Console | Symfony Console | Laravel Zero | Silly | |
|---|---|---|---|---|
| Dependencies | 4 | 0 (is the dep) | 30+ | 2 |
| Install size | ~100KB + Symfony | ~600KB | ~15MB+ | ~30KB + Symfony |
| Command style | Class + Closures | Class only | Class | Closures only |
| DI Container | ✅ PSR-11 | ❌ | ✅ | ✅ |
| Scheduler | ✅ Full-featured | ❌ | ✅ | ❌ |
| Command locking | ✅ Built-in | Manual | ❌ | ❌ |
| Overlap prevention | ✅ Symfony Lock | ❌ | ✅ | ❌ |
| Conditional scheduling | ✅ when(), skip(), between() |
❌ | ✅ | ❌ |
| Output capture | ✅ | ❌ | ✅ | ❌ |
| Background execution | ✅ | ❌ | ✅ | ❌ |
| Webhook/ping | ✅ | ❌ | ✅ | ❌ |
| Maintenance mode | ✅ | ❌ | ✅ | ❌ |
| Reusable traits | ✅ 8 traits | ❌ | ❌ | ❌ |
License
MIT — See LICENSE for details.
simsoft/console 适用场景与选型建议
simsoft/console 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 250 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「php」 「cli」 「console」 「cron」 「command」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 simsoft/console 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 simsoft/console 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 simsoft/console 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The bundle for easy using json-rpc api on your project
Bundle Symfony DaplosBundle
Slim starter / Slim skeleton package to boost your development with Slim framework
Generates a trait to help ease the access of custom repo methods
Alfabank REST API integration
Eco CLI for Laravel .env syncing
统计信息
- 总下载量: 250
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-04