composer and ecosystem
PHP-FIG
PHP-FIG is a group that publishes interoperability recommendations and PHP Standards Recommendations, commonly called PSRs. These standards let packages cooperate without sharing one framework.
Why Interoperability Matters
An application often needs a logger, cache, HTTP client, or dependency-injection container. Without shared contracts, each library would accept a different kind of object. A PSR gives package authors a common interface to work against.
PHP-FIG does not publish a framework and it does not require an application to adopt every PSR. Projects use the recommendations that solve a real integration problem. A Laravel, Symfony, or framework-free application may all depend on selected PSRs.
Interfaces And Implementations
A standards package usually defines interfaces rather than doing the work itself. For example, psr/log provides Psr\Log\LoggerInterface. An application still needs an implementation such as Monolog or a framework logger.
This distinction matters when reading documentation. The PSR tells you which methods consumers may rely on. The implementation documentation tells you how to configure handlers, storage, retries, or other runtime behaviour.
<?php
declare(strict_types=1);
use Psr\Log\LoggerInterface;
final class PaymentReporter
{
public function __construct(private LoggerInterface $logger)
{
}
public function reportFailure(string $paymentId): void
{
$this->logger->warning('Payment failed', [
'payment_id' => $paymentId,
]);
}
}
PaymentReporter does not need to know which logger receives the message. The application bootstrap or service container chooses that implementation.
Using PSRs Sensibly
Look for standards at boundaries where packages meet: logs, HTTP messages, cache access, clocks, and containers. Do not add an interface merely to make a small local helper look more abstract. Existing project conventions still matter, and replacing a well-understood local abstraction may create work without improving the application.
Practice
Practice: Identify Useful Interoperability Points
Identify the interoperability boundaries in a small PHP application and map each useful boundary to a PHP-FIG standard.
Requirements
- Name logger, cache, HTTP, and container boundaries.
- Connect each to an applicable PSR.
- Separate interfaces from implementations.
- Explain when an existing local abstraction is enough.
Show solution
Map logging to PSR-3, caching to PSR-6 or PSR-16, outgoing HTTP calls to PSR-18, and container integration to PSR-11. Each PSR supplies a contract; a configured implementation still does the actual work.
Use a PSR where packages meet or infrastructure may reasonably change. Keep an established local abstraction when replacing it would add ceremony without improving integration.