- How do I install league/climate in a Laravel project?
- Run `composer require league/climate` in your project root. No Laravel-specific setup is needed—just require the autoloader and instantiate the `CLImate` class. Works standalone or with Laravel’s service container.
- Can I use CLImate in Laravel Artisan commands?
- Yes. Inject the `CLImate` instance into your `Command` class constructor via Laravel’s service container. Replace `echo` with methods like `$climate->info()` or `$climate->table()` for consistent, styled output.
- Does league/climate support Windows terminals?
- Yes, starting with version 3.1.1. CLImate automatically handles ANSI escape sequences for Windows, including password masking and colored output. Tested on Windows 10/11 and modern terminals.
- How do I add progress bars to Laravel migrations?
- Use `$climate->progress()->start('Migrating...')` before your migration loop, then call `$climate->progress()->advance()` for each step. Finish with `$climate->progress()->finish()`. Works seamlessly with Laravel’s migration system.
- Is league/climate compatible with Laravel 10+ and PHP 8.2+?
- Yes. CLImate supports PHP 8.1–8.4 and Laravel 9/10. Check the [release notes](https://github.com/thephpleague/climate/releases) for version-specific features. The latest stable version (3.x) is fully backward-compatible.
- Can I customize CLImate’s colors for my Laravel app’s branding?
- Absolutely. Extend the default palette using `CLImate::extend()` or override colors in your `CLImate` instance. Example: `$climate->setOption('colors', ['primary' => '#3b82f6'])` for Tailwind-like themes.
- How do I test terminal output in PHPUnit?
- Use a hybrid approach: unit test logic (e.g., method calls) and integration tests for visual output. Mock `$climate->output` for unit tests, or capture STDOUT with `expectOutputString()` in PHPUnit for integration tests.
- Does CLImate work with Laravel’s queue workers?
- Yes. Use spinners or progress bars to show real-time job status. Example: `$climate->spinner()->start('Processing job...'); $job->handle(); $climate->spinner()->finish()`. Ideal for long-running queue jobs.
- What’s the difference between CLImate and Symfony’s Console component?
- CLImate is lighter and focused on output styling (colors, tables, progress bars), while Symfony’s Console offers advanced features like multi-step forms and complex prompts. Use CLImate for simple CLI tools and Symfony for interactive workflows.
- How do I handle CLImate errors in Laravel’s logging system?
- Integrate CLImate with Laravel’s `Log` facade by setting a PSR-3 logger. Example: `$climate->setLogger(app(Log::class))`. Exceptions (e.g., `InvalidArgumentException`) will then log via Laravel’s default channels.