AppServiceProvider or modular service providers to dynamically resolve PSR-compliant services (e.g., replacing HttpClient bindings with discovered implementations).Illuminate\Contracts\Container\Container for PSR-11, Log facade for PSR-3).composer.json version constraints.HttpClient) may override or conflict with discovered implementations. Test edge cases where Laravel’s built-in services shadow PSR standards.guzzlehttp/guzzle:^7.0) be managed to avoid conflicts?Illuminate\Contracts\Http\Client\Factory, Psr\Log\LoggerInterface). Reduces boilerplate for integrating third-party PSR-compliant libraries.guzzlehttp/guzzle, symfony/http-client, monolog/monolog) to identify gaps or redundancies.require guzzlehttp/guzzle:^7.0) that could be replaced with discovery.Log::getMonolog() with a discovered PSR-3 logger in a plugin.bind(Psr\Http\Client\ClientInterface::class, fn() => discover(Psr18Client::class))).config('discovery.enabled') (if extended) to toggle discovery globally.psr-discovery/all:^1.0). Test for regressions in older versions if supporting them.composer require to pull compatible versions.composer require psr-discovery/http-client-implementations ensures Guzzle/Symfony clients are available.Illuminate\Http\Client\PendingRequest) may not be discoverable via PSR interfaces. Document workarounds or stick to pure PSR interfaces.composer require psr-discovery/all psr-discovery/http-client-implementations psr-discovery/log-implementations
// app/Providers/AppServiceProvider.php
use Psr\Discovery\Discovery;
use Psr\Http\Client\ClientInterface;
public function register(): void
{
$this->app->bind(ClientInterface::class, function () {
return Discovery::findProvider(ClientInterface::class);
});
}
public function test_psr18_client_discovery()
{
$client = app(ClientInterface::class);
$this->assertInstanceOf(GuzzleHttp\Client::class, $client);
}
No implementation found for Psr\Log\LoggerInterface) to catch missing dependencies early.composer.json and service providers.psr-discovery/all and installing corresponding discovery packages (e.g., psr-discovery/cache-implementations).composer why-not to audit dependencies.composer show can verify installed PSR implementations.composer.json template for dependencies:
{
"require": {
"psr-discovery/all": "^1.2",
"guzzlehttp/guzzle": "^7.0", // Example implementation
"symfony/http-client": "^6.0" // Alternative
}
}
composer require).$this->app->singleton(ClientInterface::class, fn() => Discovery::findProvider(ClientInterface::class));
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| No PSR implementation installed | Runtime exception on discovery | Document requirements; provide fallback logic. |
| Incompatible PSR versions | Discovery returns broken instance | Enforce version constraints in composer.json. |
| Multiple conflicting implementations | Undefined behavior (first match) | Test all combinations; prioritize via naming. |
| Laravel-specific overrides | PSR discovery ignored | Use explicit bindings for Laravel services. |
| Composer autoload failure |
How can I help you explore Laravel packages today?