laranail/console
Laranail Console extends Laravel's Artisan CLI with convenient commands and helpers for common development and maintenance tasks, streamlining terminal workflows and making it easier to manage your application from the command line.
Strengths:
artisan) by providing structured, visually rich output (tables, trees, progress bars) and interactive prompts/forms.Illuminate\Validation), enabling reuse of existing logic.Fit for Use Cases:
schedule:run output with progress tracking or interactive confirmations.dd()/dump() with formatted tables or trees for large datasets.make:model with custom prompts) without reinventing the wheel.Potential Misalignment:
echo/error() output, the package may introduce unnecessary complexity.Laravel Ecosystem Compatibility:
Artisan (extends Illuminate\Console).ConsoleServiceProvider registration (if not auto-discoverable).Key Integration Points:
echo, table(), or line() in existing commands with Console::table(), Console::progress(), etc.input() calls with Console::prompt()->validate() for structured user input.Rule::unique()) within Console::form() for consistency.Testing Impact:
phpunit --testdox or Symfony’s ConsoleTestCase).Low to Medium:
Console::isInteractive()).Mitigation Strategies:
Console::table() before prompts).Laravel Native:
Illuminate\Console\Command with laranail/console methods.Console facade into commands or bind it globally.Console::render('admin.table')).Non-Laravel PHP:
symfony/console for core CLI, laranail/console for rich output).Tooling Compatibility:
Phase 1: Output Enhancement
echo/table() calls in existing commands with Console::table(), Console::progress(), etc.// Before
$this->table(['ID', 'Name'], $users->toArray());
// After
Console::table(['ID', 'Name'], $users->map(fn($u) => [$u->id, $u->name]));
Phase 2: Interactive Prompts
input()/confirm() with Console::prompt() and Console::confirm().// Before
$name = $this->ask('Enter name');
if (!$this->confirm('Continue?')) exit;
// After
$name = Console::prompt('Enter name')->required();
if (!Console::confirm('Continue?')) exit;
Phase 3: Forms/Validation
Console::form() with Laravel validators.$data = Console::form([
'email' => ['type' => 'email', 'rules' => 'required|email'],
'age' => ['type' => 'number', 'rules' => 'min:18'],
])->validate();
Phase 4: Custom Components
Console::tree() for nested data) or themes.Backward Compatibility:
Environment-Specific Handling:
if (!Console::isInteractive()) {
Console::warn('Skipping interactive prompts in non-TTY mode.');
}
Testing Compatibility:
Console facade for isolated testing.symfony/console/Tester or custom test runners for interactive scenarios.| Priority | Task | Dependencies | Effort |
|---|---|---|---|
| High | Replace basic output (echo, table) |
None | Low |
| Medium | Add progress bars/spinners | Phase 1 output enhancements | Medium |
| Medium | Migrate prompts (ask, confirm) |
Phase 1 | Medium |
| Low | Adopt forms/validation | Laravel validation rules | High |
| Low | Custom themes/renderers | Core integration complete | Medium |
Rollout Strategy:
debug:config).Pros:
config/console.php).Cons:
Maintenance Tasks:
How can I help you explore Laravel packages today?