Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Climate Laravel Package

league/climate

League CLImate makes PHP CLI output nicer with easy colored text, formatting, and styled messages. Install via Composer and use a simple API to print red, blue, and more, helping your command-line scripts look clean and readable.

View on GitHub
Deep Wiki
Context7

league/climate (CLImate) is a PHP library for building polished command-line output. It makes it easy to print colored text, apply formatting, and present information in a more readable way when running PHP scripts in the terminal.

Install via Composer and use the fluent API to style messages quickly—ideal for CLI tools, deploy scripts, and interactive console apps.

  • Colorized output (e.g., red, blue, etc.) for emphasis and clarity
  • Convenient methods for styled/structured terminal text
  • Lightweight, developer-friendly API for quick adoption
  • Works seamlessly in typical PHP CLI workflows
  • Maintained by The PHP League ecosystem
Frequently asked questions about Climate
How do I use league/climate in a Laravel Artisan command?
Install via `composer require league/climate`, then inject the `OutputInterface` from Symfony’s Console component into your command. Create a `CLImate` instance and chain methods like `$climate->blue('Success!')->display()`. For cleaner usage, wrap it in a service provider or facade.
Does league/climate work with Laravel 10 and PHP 8.4?
Yes, league/climate supports Laravel 10+ and PHP 8.1+. For PHP 8.4, ensure you’re using version **3.10+** (check the [release notes](https://github.com/thephpleague/climate/releases)). It’s fully backward-compatible with PHP 7.4+ but drops PHP 7.2 support in v3.7.0.
Can I use league/climate for progress bars in Laravel queues?
Absolutely. Use `$climate->progress()->start()` before looping through jobs, then call `$climate->progress()->advance()` after each job. For async tasks, combine it with `dispatchSync()` or Laravel’s job queues. Example: `$climate->progress()->each($jobs, fn($job) => $job->handle());`
How do I handle non-ANSI terminals (e.g., Windows CMD) with league/climate?
Enable ANSI output explicitly with `$climate->forceAnsiOn()`. For legacy systems, test on Windows Subsystem for Linux (WSL) or document fallbacks. The library supports Windows/macOS/Linux, but edge cases may require manual overrides.
Is league/climate safe for production Laravel deployments?
Yes, it’s lightweight (~1–5ms per operation) and production-ready. For heavy operations like progress bars, cache updates or batch them. Avoid mixing CLImate’s logger with Laravel’s HTTP logs to prevent conflicts.
Can I create interactive prompts (e.g., confirmations) for non-developers?
Yes, use methods like `$climate->confirm('Proceed?')` or `$climate->checkboxes(['Option 1', 'Option 2'])` for self-service CLI tools. However, test UX thoroughly—interactive prompts add complexity and may require additional validation.
How do I style tables in Laravel Artisan commands with league/climate?
Use `$climate->table(['headers'], $rows)` to generate formatted tables. For dynamic data, fetch records and pass them as an array. Example: `$climate->table(['ID', 'Name'], $users->toArray())->display()`. Works seamlessly with Laravel Collections.
What’s the best way to standardize league/climate across a Laravel project?
Create a custom facade (e.g., `CLI::blue('Text')`) or service provider to centralize usage. This reduces boilerplate and ensures consistency. Example: `CLI::info()->table($data)->display();` in all commands.
Are there alternatives to league/climate for Laravel CLI styling?
Yes, consider Symfony’s `Console` component (built into Laravel) for basic styling, or `symfony/console` for advanced features. For minimalism, `bobthecow/console` is another option. However, league/climate stands out for its fluent API and modular features like progress bars.
How do I test league/climate output in PHPUnit for Laravel?
Use PHPUnit’s `expectOutputString()` or mock `OutputInterface` to capture styled output. For cross-platform testing, include Windows/macOS/Linux in your GitHub Actions matrix. Example: `$this->expectOutputString($climate->blue('Test')->render());`
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport