Search by

raxos / contract

basmilius

Interfaces used in Raxos.

3.2.0 2026-10-02 17:09 UTC

This package is auto-updated.

Last update: 2026-10-03 12:05:54 UTC


README

Bas Milius

Raxos Contract

Shared interfaces for Raxos implementations and application extension points.

Documentation | Packagist | Raxos

  • Contracts for collections, containers, HTTP, routing, databases and caching.
  • Mail, message-bus, rate-limit, search, barcode and wallet extension points.
  • Common exception, debugging and serialization interfaces.

Installation

Requires PHP 8.5 or later. Enable the pdo PHP extension. Composer checks the remaining package and extension dependencies declared in composer.json.

composer require "raxos/contract:^3.2"

Usage

<?php
declare(strict_types=1);

use Raxos\Contract\SerializableInterface;

require __DIR__ . '/vendor/autoload.php';

final class Preferences implements SerializableInterface
{
    public function __construct(public bool $darkMode = false) {}

    public function __serialize(): array
    {
        return ['dark_mode' => $this->darkMode];
    }

    public function __unserialize(array $data): void
    {
        $this->darkMode = (bool)($data['dark_mode'] ?? false);
    }
}

$preferences = new Preferences(darkMode: true);
$restored = unserialize(serialize($preferences), ['allowed_classes' => [Preferences::class]]);

Install an implementation package when you need a working client, container or database connection. When upgrading custom implementations to 3.2, review the collection, cursor, ORM-cache and message-queue contract changes in the migration guide. The OAuth factory contracts live in raxos/oauth2.

Documentation

Testing

Run this library's Pest suite from the Raxos workspace:

git clone --recurse-submodules https://github.com/basmilius/raxos.git
cd raxos
composer install
vendor/bin/pest --testsuite=contract

See Testing Raxos for PHP extensions, integration services and coverage commands. The library's Tests workflow also runs in GitHub Actions.

License

MIT. Copyright (c) 2017 - present Bas Milius.