Installation & Requirements
Winter Logger installs with Composer. Logging output depends on one optional package — Monolog — and the library is designed to run happily with or without it.
System requirements
- PHP version — 8.3 or higher.
psr/log^3.0— the PSR-3 interfaces (installed automatically).monolog/monolog^3.5— suggested. Required for any real log output.ext-swoole(orext-openswoole) — optional. Only needed forCoroutineContextunder Swoole.
Install
With Monolog — the normal setup, produces real log output:
composer require flytachi/winter-logger monolog/monologWithout Monolog — every logger becomes a silent NullLogger:
composer require flytachi/winter-loggerWhy Monolog is optional
Monolog is declared under suggest in composer.json, so Composer never installs it
automatically. Consumers can opt out of logging entirely — no code changes required.
Optional dependencies
| Package | Purpose |
|---|---|
monolog/monolog ^3.5 |
Required for actual log output. Without it, loggers are no-ops. |
ext-swoole |
Coroutine-local context in Swoole (CoroutineContext). |
ext-openswoole |
Alternative to ext-swoole. |
Monolog-free mode
When monolog/monolog is not installed, LoggerManager::channel()
returns a Psr\Log\NullLogger for every channel. No exceptions, no warnings — the code
just runs silently. This is useful for:
- Libraries that support logging optionally.
- Microservices where logging is toggled per environment.
- Tests where log output is irrelevant.
The full reasoning — and the exact code path — is in Deep dive → Monolog is optional.
Framework integration
The library never touches getenv(), $_ENV, or any infrastructure detection. In
winter-kernel, the framework reads env vars, resolves the output target
(stdout / stderr / syslog / file), picks the right ContextStorage for the runtime
(FPM / Swoole / CLI), and passes the finished config to LoggerManager.
For wiring it up yourself, see Framework integration.
Next
- Quickstart — first request-scoped log line in five minutes
- Mental model — the three ideas behind the package
- Channel config reference — every config key