PHPackages                             solophp/contracts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. solophp/contracts

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

solophp/contracts
=================

Contracts and interfaces for Solo ecosystem

v1.3.0(2mo ago)0124↓100%7MITPHPPHP ^8.1

Since Oct 13Pushed 2mo agoCompare

[ Source](https://github.com/SoloPHP/Contracts)[ Packagist](https://packagist.org/packages/solophp/contracts)[ RSS](/packages/solophp-contracts/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (7)

SoloPHP Contracts
=================

[](#solophp-contracts)

[![Latest Version on Packagist](https://camo.githubusercontent.com/36fb34a0efc0c566017fd3c7b3c16832f9ef1282560bb5a5cb507d9ccd9fb337/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f6c6f7068702f636f6e7472616374732e737667)](https://packagist.org/packages/solophp/contracts)[![License](https://camo.githubusercontent.com/8d6f87b44623e7e1e042f790efc27a4b4db7cc63e63c396fd93b7ca92f5043ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736f6c6f7068702f636f6e7472616374732e737667)](https://github.com/solophp/contracts/blob/main/LICENSE)[![PHP Version](https://camo.githubusercontent.com/1773888d0a37a3538c86b5209742d761ad08a9e0c3920841564e308ef1ddd758/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736f6c6f7068702f636f6e7472616374732e737667)](https://packagist.org/packages/solophp/contracts)

A collection of interfaces and contracts for the SoloPHP ecosystem. This package provides standardized contracts that enable interoperability between different SoloPHP components and allow developers to create custom implementations.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require solophp/contracts
```

Available Contracts
-------------------

[](#available-contracts)

### Router

[](#router)

**`RouterInterface`** - Framework-agnostic interface for HTTP routing implementations.

```
use Solo\Contracts\Router\RouterInterface;

class MyRouter implements RouterInterface
{
    public function addRoute(string $method, string $path, $handler, array $options = []): object
    {
        // Your implementation
        return $this; // Enables fluent interface
    }

    public function match(string $method, string $uri): array|false
    {
        // Your implementation
    }
}
```

### Job Queue

[](#job-queue)

**`JobInterface`** - Interface for executable job classes.

```
use Solo\Contracts\JobQueue\JobInterface;

class SendEmailJob implements JobInterface
{
    public function handle(): void
    {
        // Job execution logic
    }
}
```

**`JobQueueInterface`** - Interface for job queue implementations with support for scheduling, retries, and job processing.

```
use Solo\Contracts\JobQueue\JobQueueInterface;

class DatabaseJobQueue implements JobQueueInterface
{
    public function push(JobInterface $job, ?string $type = null, ?DateTimeImmutable $scheduledAt = null, ?DateTimeImmutable $expiresAt = null): int
    {
        // Add job to queue
    }

    // Implement other methods: addJob, getPendingJobs, processJobs, markCompleted, markFailed
}
```

### Validator

[](#validator)

**`ValidatorInterface`** - Interface for data validation implementations.

```
use Solo\Contracts\Validator\ValidatorInterface;

class MyValidator implements ValidatorInterface
{
    public function validate(array $data, array $rules): array
    {
        // Validation logic
        // Returns structured errors: ['field' => [['rule' => 'required', 'params' => [...]], ...]]
        return $errors;
    }
}
```

### Container

[](#container)

**`WritableContainerInterface`** - Extends PSR-11 ContainerInterface with write capability for service registration.

```
use Solo\Contracts\Container\WritableContainerInterface;

class MyContainer implements WritableContainerInterface
{
    public function set(string $id, callable $factory): void
    {
        // Register service factory
    }

    public function get(string $id): mixed
    {
        // Retrieve service
    }

    public function has(string $id): bool
    {
        // Check if service exists
    }
}
```

### Http

[](#http)

**`EmitterInterface`** - Interface for HTTP response emitters that send PSR-7 responses to the client.

```
use Solo\Contracts\Http\EmitterInterface;

class SapiEmitter implements EmitterInterface
{
    public function emit(ResponseInterface $response): void
    {
        // Emit headers and body to client
    }
}
```

Usage
-----

[](#usage)

```
{
    "require": {
        "solophp/contracts": "^1.0"
    }
}
```

Benefits
--------

[](#benefits)

- **Interoperability** - Components built on these contracts work together seamlessly
- **Flexibility** - Swap implementations without changing dependent code
- **Type Safety** - Strong typing ensures contract compliance
- **Framework Agnostic** - Use in any PHP project

License
-------

[](#license)

MIT

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance84

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~42 days

Total

4

Last Release

81d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f29817cec408d033cd4441c8f760e3ae40248dc0f66856a09080d282aee6959?d=identicon)[Vitaliy Olos](/maintainers/Vitaliy%20Olos)

---

Top Contributors

[![SoloPHP](https://avatars.githubusercontent.com/u/175482616?v=4)](https://github.com/SoloPHP "SoloPHP (11 commits)")

### Embed Badge

![Health badge](/badges/solophp-contracts/health.svg)

```
[![Health](https://phpackages.com/badges/solophp-contracts/health.svg)](https://phpackages.com/packages/solophp-contracts)
```

###  Alternatives

[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[league/container

A fast and intuitive dependency injection container.

86387.8M342](/packages/league-container)[lctrs/psalm-psr-container-plugin

Let Psalm understand better psr11 containers

17648.1k13](/packages/lctrs-psalm-psr-container-plugin)[phpwatch/simple-container

A fast and minimal PSR-11 compatible Dependency Injection Container with array-syntax and without auto-wiring

1810.1k2](/packages/phpwatch-simple-container)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
