PSR
PHP contracts for HTTP, containers, logging and caching.
Installation
Section titled “Installation”composer config repositories.localzet-psr vcs https://github.com/localzet/PSRcomposer require localzet/psr:dev-mainPSR contracts
Section titled “PSR contracts”The package contains interfaces and helper types for HTTP, Container, Log, Cache, SimpleCache, EventDispatcher and Clock. CacheInterface does not supply a cache backend; ContainerInterface does not supply a working DI container. Applications choose implementations.
Review autoload/replace declarations and the Composer dependency tree before installation: conflicting copies must not load the same Psr namespaces. A PSR-related name is not certification of implementation compliance. Match the actual signature and the consuming package’s version requirements.
Requirements
Section titled “Requirements”- php: ^8.2
Example
Section titled “Example”<?php
declare(strict_types=1);
use localzet\PSR\Clock\ClockInterface;use localzet\PSR\Log\AbstractLogger;
require __DIR__ . '/vendor/autoload.php';
$logger = new class extends AbstractLogger { public array $records = [];
public function log($level, string|Stringable $message, array $context = []): void { $this->records[] = [$level, (string) $message, $context]; }};$clock = new class implements ClockInterface { public function now(): DateTimeImmutable { return new DateTimeImmutable('2026-10-17T12:00:00+00:00'); }};
$logger->info('Order created', ['order_id' => 42]);echo json_encode([$logger->records[0], $clock->now()->format(DATE_ATOM)], JSON_THROW_ON_ERROR), PHP_EOL;Source · AGPL-3.0