psr-discovery/log-implementations
Discover available PSR-3 logger implementations at runtime without hard dependencies. Searches for well-known classes and returns the first compatible LoggerInterface instance, ideal for SDKs and libraries; supports multiple popular loggers and mocking/testing options.
Standardized Logging for Laravel Ecosystem Packages: Enable Laravel packages (e.g., auth, payment gateways, analytics) to support PSR-3 logging without forcing users to configure dependencies. Reduces friction for developers integrating your package into Laravel apps. Example: A package could auto-detect Monolog (Laravel’s default) or Laminas Log without requiring explicit setup.
Decoupled Plugin Architecture: Build modular Laravel plugins where logging is optional but pluggable. Users can inject their preferred logger (e.g., Monolog, Cloud Logging) without breaking changes. Aligns with Laravel’s service provider pattern for extensibility.
Testing and CI/CD Optimization:
Prioritize mock implementations (e.g., psr-mock/log-implementation) in PHPUnit/Pest tests to eliminate flaky tests caused by real logging dependencies. Ensures CI pipelines run faster and more reliably.
Roadmap: "Bring Your Own Logger" (BYOL) for Laravel: Justify a BYOL feature in your Laravel package by leveraging this package to auto-detect and delegate to user-provided loggers. Reduces support overhead for edge cases (e.g., users with custom logging setups).
Build vs. Buy Decision:
Buy: Use this package to avoid reinventing logger discovery logic in Laravel packages. Build: Only if you need custom discovery rules (e.g., prioritizing Laravel’s built-in logger or cloud-specific loggers like google/cloud-logging).
Performance-Critical Packages: Reduce bundle size and startup overhead by avoiding hard dependencies on logging libraries. Ideal for Laravel packages where performance is critical (e.g., high-frequency APIs, real-time systems).
Adopt if:
config/logging.php required).Look elsewhere if:
Log::channel()).psr-discovery/log-implementations:^1.0).Log facade exclusively).For Executives: "This package lets our Laravel packages automatically use the customer’s preferred logger—whether it’s Laravel’s default, Monolog, or Laminas—without forcing them to configure anything. It’s like ‘auto-detect’ for logging, which reduces support tickets, speeds up integrations, and keeps our packages lean. For example, a developer using our payment gateway package can just install Monolog if they want, and our package will use it seamlessly. Mock support also ensures our tests run faster and more reliably in CI/CD. This is a no-brainer for packages targeting the Laravel ecosystem."
For Engineering (Laravel Team): *"This solves the ‘chicken-and-egg’ problem of requiring users to configure logging in our Laravel packages. Key benefits:
prefer() or use() specific loggers if needed (e.g., for cloud integrations or Laravel-specific setups).Tradeoff: We cede some control over logging behavior, but the flexibility outweighs the cost for a Laravel package. Example use case: Our analytics module can now log to any PSR-3-compatible system without breaking changes or requiring user configuration.*
For Developers (Package Contributors):
*"Add this to your Laravel package’s composer.json:
composer require psr-discovery/log-implementations
Then use Discover::log() to get a PSR-3 logger instance. It’ll pick the first available logger (or a mock in tests). No config needed—just works. Need to force a specific logger? Use:
use PsrDiscovery\Implementations\Psr3\Logs;
Logs::use('monolog/monolog'); // Force Monolog
$log = Discover::log();
Or prefer Laravel’s default logger:
Logs::prefer('monolog/monolog'); // Prefer Monolog over others
Works seamlessly with Laravel’s service container and testing tools like Pest/PHPUnit."*
For Laravel Core Team (if proposing integration): *"This package could be integrated into Laravel’s core to enable ‘auto-detect’ logging for third-party packages. For example:
Log::driver() to delegate to Discover::log() for dynamic resolution.LogServiceProvider that falls back to discovered loggers if no config is set.Discover::logs() to inspect available implementations for runtime decisions (e.g., feature flags based on logging capabilities).This would reduce the barrier for packages to support logging without requiring users to configure config/logging.php."*
How can I help you explore Laravel packages today?