PHPackages                             complex-heart/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. complex-heart/contracts

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

complex-heart/contracts
=======================

Common interfaces for PHP Complex Heart SDK.

v3.0.0(7mo ago)12.8k3Apache-2.0PHPPHP ^8.2CI passing

Since May 30Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/ComplexHeart/php-contracts)[ Packagist](https://packagist.org/packages/complex-heart/contracts)[ RSS](/packages/complex-heart-contracts/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (6)Used By (3)

Contracts
=========

[](#contracts)

[![Test](https://github.com/ComplexHeart/php-contracts/actions/workflows/test.yml/badge.svg)](https://github.com/ComplexHeart/php-contracts/actions/workflows/test.yml)

Common interfaces for PHP Complex Heart SDK.

Domain Layer
------------

[](#domain-layer)

### Model

[](#model)

Core building blocks for domain-driven design:

- **Aggregate** - Root entity with domain event publishing
- **Entity** - Domain object with unique identity
- **ValueObject** - Immutable domain value with equality
- **Identifier** - Unique identifier representation

### Events

[](#events)

Domain event interfaces following ISP (Interface Segregation Principle):

- **Event** - Base domain event (eventId, eventName, payload, occurredOn)
- **Traceable** - Distributed tracing (correlationId, causationId)
- **Sourceable** - Event sourcing (aggregateId, aggregateType, eventVersion)
- **EventBus** - Publishes domain events

Application Layer
-----------------

[](#application-layer)

### Command

[](#command)

Write operations (CQRS):

- **Command** - Marker interface for state-changing operations
- **CommandBus** - Dispatches commands to handlers
- **CommandHandler** - Executes commands

### Query

[](#query)

Read operations (CQRS):

- **Query** - Marker interface for data retrieval
- **QueryResponse** - Marker interface for query results
- **QueryBus** - Routes queries to handlers
- **QueryHandler** - Executes queries and returns responses

### Handler

[](#handler)

Event handlers:

- **EventHandler** - Reacts to domain events

### Service Bus

[](#service-bus)

Unified message bus facade:

- **ServiceBus** - Provides access to CommandBus, QueryBus, and EventBus

Architecture
------------

[](#architecture)

This library follows Clean Architecture principles with explicit layer separation:

- **Domain → Application** - Domain layer is independent, Application depends on Domain
- **Layer-Explicit Namespaces** - Clear architectural boundaries in namespace structure
- **Interface Segregation** - Compose only needed capabilities (e.g., Event + Traceable + Sourceable)

### Architecture Testing

[](#architecture-testing)

The project includes automated architecture tests using Pest PHP:

```
composer test
```

Tests enforce:

- Domain layer independence (no Application dependencies)
- Correct interface placement and usage
- Clean Architecture dependency rules
- PHP and security best practices (via arch presets)

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance77

Regular maintenance activity

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 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 ~399 days

Total

5

Last Release

216d ago

Major Versions

v0.1.0 → v1.0.02022-05-23

v1.0.0 → v2.0.02024-01-01

v2.0.1 → v3.0.02025-10-14

PHP version history (3 changes)v0.1.0PHP ^7.4|^8.0

v2.0.0PHP ^8.1

v3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7958790dcf5cd51ebbadc52fc7bada326fb3edd4481decf1006e6cfed8e46c43?d=identicon)[usantisteban](/maintainers/usantisteban)

---

Top Contributors

[![othercodes](https://avatars.githubusercontent.com/u/4815856?v=4)](https://github.com/othercodes "othercodes (14 commits)")

---

Tags

clean-architecturecontractsinterfaces

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sastrawi/sastrawi

PHP library for stemming Indonesian language (Bahasa Indonesia)

43972.0k4](/packages/sastrawi-sastrawi)[magefan/module-wysiwyg-advanced

Extend TinyMCE 4 in Magento 2

762.3M1](/packages/magefan-module-wysiwyg-advanced)[protonlabs/bitcoin

PHP Bitcoin library with functions for transactions, signatures, serialization, Random/Deterministic ECDSA keys, blocks, RPC bindings

33187.4k8](/packages/protonlabs-bitcoin)[webtorque7/inpage-modules

Adds module blocks to a SilverStripe website.

191.3k](/packages/webtorque7-inpage-modules)

PHPackages © 2026

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