adhocore/cli
A lightweight PHP library to build interactive CLI apps with commands, options, prompts, and colored output. Create structured command-line tools quickly, with input helpers and utilities suited for both simple scripts and larger console applications.
--help) and styled output align with Laravel’s conventions (e.g., Artisan’s --ansi flag support), reducing friction for developers familiar with Laravel’s CLI.--verbose flags, styled progress bars).bash scripts with PHP CLI apps using adhocore/cli for cross-platform compatibility.php artisan adhocore:process-jobs --limit=100).php deploy:check --confirm).getopt() or Symfony\Component\Console.| Risk Area | Mitigation Strategy |
|---|---|
| Dependency Conflicts | Low risk: MIT-licensed, no major PHP framework dependencies (only symfony/console as optional). |
| Laravel-Specific Gaps | Limited Laravel integration (e.g., no direct ServiceProvider hooks), but can be extended via facades. |
| Performance Overhead | Negligible for CLI tools; benchmark against raw symfony/console if critical. |
| Adoption Curve | Steep for teams unfamiliar with CLI patterns, but Laravel devs will adapt quickly. |
--ansi flag) in custom CLI apps?App\Exceptions\Handler) integrate seamlessly with CLI errors?Symfony\Component\Console\Tester\CommandTester.)php artisan adhocore:db:optimize).bash scripts with PHP CLI apps (e.g., php vendor/bin/my-tool --input=file.json).laravel-echo or laravel-horizon CLI with custom prompts (e.g., php queue:flush --confirm).[Option] for metadata).| Phase | Action | Tools/Libraries |
|---|---|---|
| Assessment | Audit existing CLI scripts (bash/Python) for migration candidates. | shellcheck, phpstan |
| Pilot | Rewrite 1–2 non-critical scripts (e.g., php artisan adhocore:generate:test-data). |
adhocore/cli, phpunit |
| Integration | Extend Artisan commands with adhocore/cli for shared UX (e.g., help menus, colors). |
Laravel Facades, Illuminate/Console |
| Optimization | Replace custom parsers (e.g., getopt()) with adhocore/cli for consistency. |
robo/robo (if using Robo tasks) |
php -r or composer exec.bash scripts with adhocore/cli apps.adhocore/cli-powered subcommands to existing Artisan groups.php artisan adhocore:queue:retry --limit=50 --dry-run.adhocore/cli.composer require adhocore/cli in composer.json.bash scripts).vendor/bin/ for distribution.stderr logging (use monolog for structured logs).adhocore/cli + Laravel CLI patterns.starter-cli Laravel package with best practices.--help for auto-generated docs).TERM=xterm-256color).tldr for CLI apps.php -r '(new \Adhocore\Cli\Cli())->run();' for debugging.symfony/console (expect <5% overhead for parsing).pcntl_fork() for parallel tasks (e.g., batch processing).| Scenario | Mitigation |
|---|---|
| Command Misuse | Validate args early (e.g., [Required] attribute). |
| ANSI Color Issues | Fallback to plain text with --no-ansi flag. |
| Dependency Conflicts | Isolate CLI tools in a separate composer.json (e.g., require-dev). |
| User Errors | Use adhocore/cli's prompts for confirmation (e.g., --confirm). |
| Laravel Environment Mismatch | Use app()->runningInConsole() to detect CLI context. |
Artisan and basic PHP CLI.@Command(name="my:command").$this->text("Hello")->bold()->green().--help for documentation.bash script maintenance time by 40%.How can I help you explore Laravel packages today?