phpdot / contracts
Shared interfaces for the PHPdot ecosystem
v0.1.0
2026-07-17 23:14 UTC
Requires
- php: >=8.5
- psr/http-message: ^2.0
- psr/http-server-handler: ^1.0
Requires (Dev)
- phpstan/phpstan: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^13.0
README
Shared interfaces for the PHPdot ecosystem. Implementation packages implement these interfaces; consumer packages type-hint against them. An implementation can be swapped without changing any consumer code, and packages never depend on each other's internals. Concrete classes and value objects live in the implementation packages, never here.
Table of Contents
Requirements
| Requirement | Constraint |
|---|---|
| PHP | >= 8.5 |
psr/http-message |
^2.0 |
psr/http-server-handler |
^1.0 |
Installation
composer require phpdot/contracts
Usage
Consume a contract by type-hinting it:
use PHPdot\Contracts\Logs\WriterInterface; final readonly class AuditService { public function __construct( private WriterInterface $writer, ) {} }
Provide a contract by implementing it:
use PHPdot\Contracts\Logs\WriterInterface; final class StdoutWriter implements WriterInterface { public function write(array $record): void { fwrite(STDOUT, json_encode($record) . PHP_EOL); } }
Every interface documents its own contract rules (MUST/SHOULD semantics) on the methods they govern.
Testing
The package is standalone-testable:
composer install composer test # PHPUnit (the e() helper) composer analyse # PHPStan, level max + strict rules composer check # Both, plus code style
License
MIT.
This repository is a read-only mirror, generated by CI from phpdot/monorepo. Pull requests and issues belong in the monorepo.