phpdot/contracts

Shared interfaces for the PHPdot ecosystem

Maintainers

Package info

github.com/phpdot/contracts

Issues

pkg:composer/phpdot/contracts

Transparency log

Statistics

Installs: 2

Dependents: 16

Suggesters: 0

Stars: 0

v0.1.0 2026-07-17 23:14 UTC

This package is auto-updated.

Last update: 2026-07-18 03:32:23 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. 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.