phpdot/contracts

Shared interfaces for the PHPdot ecosystem

Maintainers

Package info

github.com/phpdot/contracts

Issues

pkg:composer/phpdot/contracts

Transparency log

Statistics

Installs: 24

Dependents: 16

Suggesters: 0

Stars: 0

v0.2.0 2026-08-19 02:16 UTC

This package is auto-updated.

Last update: 2026-08-19 03:09:41 UTC


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. Implementations live in the implementation packages; the only concrete classes here are the pagination carriers (Paginator, CursorPaginator), because every implementation must hand consumers the same wire-stable result shape.

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
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.