PHPackages                             johnnickell/fight-common - 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. johnnickell/fight-common

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

johnnickell/fight-common
========================

A common library for $FIGHT projects

1.0.0(2w ago)038↓41.7%MITPHPPHP &gt;=8.5CI passing

Since May 22Pushed 5d agoCompare

[ Source](https://github.com/johnnickell/fight-common)[ Packagist](https://packagist.org/packages/johnnickell/fight-common)[ RSS](/packages/johnnickell-fight-common/feed)WikiDiscussions develop Synced 1w ago

READMEChangelogDependencies (28)Versions (6)Used By (0)

$FIGHT Common
=============

[](#fight-common)

[![Tests](https://github.com/johnnickell/fight-common/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/johnnickell/fight-common/actions/workflows/tests.yml)[![PHP 8.5+](https://camo.githubusercontent.com/37a4f65573cacc4cb64e2d347267cd765c71459e35407046004f24616710806b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e352532422d3838393242462e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net/)[![License: MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![Version](https://camo.githubusercontent.com/a8ded79371673f0a86c501e46ce82873ee856fbdeeced50b93ca5cb84d9c6f0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e312e302d627269676874677265656e2e737667)](CHANGELOG.md)[![PHPStan](https://camo.githubusercontent.com/2761aeebb3945f1ca4e4b0f156a71a3558c10dd6e3da83b1feb44f4d33013329/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230362d627269676874677265656e2e737667)](phpstan.neon.dist)

A shared PHP library for $FIGHT projects implementing Hexagonal (Ports &amp; Adapters) / Clean Architecture. Provides foundational building blocks including value objects, typed collections, CQRS messaging, a composable validation system, and infrastructure adapters.

**[Documentation](https://johnnickell.github.io/fight-common/)** · **[Quick Start](https://johnnickell.github.io/fight-common/quickstart/)** · **[Changelog](CHANGELOG.md)**

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

[](#requirements)

- PHP 8.5+
- Docker (for local tooling)

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

[](#installation)

```
composer require johnnickell/fight-common
```

Optional adapters require additional packages — install only what you need:

```
composer require doctrine/orm           # Doctrine data types and unit of work
composer require doctrine/dbal          # Database health check and nonce replay prevention
composer require symfony/http-kernel    # HTTP middleware and JSend response
composer require lcobucci/jwt           # JWT encoder and decoder
composer require guzzlehttp/guzzle      # HTTP client adapter
```

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

[](#architecture)

Dependencies flow inward only. The Domain has no external dependencies. The Application layer depends on Domain interfaces only. Adapters depend on both.

```
Domain      ← pure business logic, no framework dependencies
Application ← orchestrates domain via interfaces
Adapter     ← concrete infrastructure implementations

```

What's Inside
-------------

[](#whats-inside)

### Domain

[](#domain)

**Value Objects** — immutable, self-validating objects that model domain concepts:

- `StringObject`, `MbStringObject`, `JsonObject` — string and JSON primitives
- `EmailAddress`, `Uri`, `Url` — internet value types with RFC-compliant validation
- `Uuid`, `UniqueId`, `MessageId` — identifier types with multiple creation strategies

**Specifications** — composable business rules:

```
$rule = $isActive->and($hasVerifiedEmail)->and($isNotBanned->not());
$rule->isSatisfiedBy($user); // true or false
```

**Collections** — fully typed collection hierarchy:

- `ArrayList` — ordered list with sort, slice, pagination, and predicate search
- `HashSet` — set operations: union, intersection, difference, complement
- `HashTable` — key-value map with typed keys and values
- `SortedSet` / `SortedTable` — ordered structures backed by a Red-Black tree with floor, ceiling, rank, and range operations
- `ArrayStack`, `LinkedStack`, `ArrayQueue`, `LinkedQueue`, `LinkedDeque` — typed stack and queue structures

**Messaging** — CQRS message contracts:

- `CommandMessage`, `QueryMessage`, `EventMessage` with `Meta` support
- Serializable to/from array and JSON

**Repository** — pagination and result set contracts:

- `Pagination` — page, perPage, orderings
- `ResultSet` — paginated records with total count and page metadata

### Application

[](#application)

**Validation** — rule-based field validation:

```
$service->validate([
    ['field' => 'email',    'label' => 'Email',    'rules' => 'required|email'],
    ['field' => 'username', 'label' => 'Username', 'rules' => 'required|min_length[3]|max_length[20]'],
], $input);
```

**CQRS Buses** — `CommandBus` and `QueryBus` with pipeline middleware support.

**Observability** — application-layer ports for health checks, metrics, and audit logging:

- `HealthAggregator` / `HealthCheck` — compose N checks into a `HealthReport` (overall status, per-check results)
- `MetricsCollector` — `increment`, `gauge`, `histogram` with tag support; bus middleware auto-instruments handlers
- `AuditLog` / `AuditRepository` — structured business-fact records (actor, action, timestamp, context); queryable by actor, action, or time range

**Serializers** — `JsonSerializer` and `PhpSerializer` for message serialization.

**Container** — PSR-11 compatible service container with singleton and factory registration.

### Adapters

[](#adapters)

AdapterRequiresDoctrine data types (`Uuid`, `Uri`, `Url`, `StringObject`, `JsonObject`, etc.)`doctrine/dbal``DoctrineUnitOfWork``doctrine/orm``SimpleEventDispatcher`, `ServiceAwareEventDispatcher`—`RoutingCommandBus`, `RoutingQueryBus`—`MetricsCommandFilter`, `MetricsQueryFilter`—`HealthReporter`, `DatabaseHealthCheck``doctrine/dbal``HttpEndpointHealthCheck`any `HttpClient` adapter`NullMetricsCollector`, `NullAuditLog`—`StatsDMetricsCollector``ext-sockets``LoggingAuditLog`any PSR-3 logger`HmacAuthenticator`, `HmacRequestService`, `HmacWebhookDispatcher`—`InMemoryNonceRepository`—`DoctrineNonceRepository``doctrine/dbal``PhpPasswordHasher`, `PhpPasswordValidator`—`JwtEncoder`, `JwtDecoder``lcobucci/jwt``JsonRequestMiddleware`, `JSendResponse``symfony/http-foundation``SymfonyFilesystem``symfony/filesystem``EventSubscriberCompilerPass``symfony/dependency-injection`Development
-----------

[](#development)

All tooling runs inside a PHP 8.5 Docker container via scripts in `./bin/`. Never use `vendor/bin/` directly.

```
./bin/phpunit                  # run full test suite with coverage
./bin/phpunit --filter foo     # run a single test by name
./bin/rector process src/      # run code modernization
./bin/composer require pkg     # manage dependencies
```

### Coverage

[](#coverage)

100% code coverage is required and enforced by PHPUnit configuration. All test classes must declare `#[CoversClass]`.

License
-------

[](#license)

MIT

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance98

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.2% 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 ~0 days

Total

2

Last Release

19d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f55553a20684ffb5ce7b1c2760fdb7ba039205d0ba8c17c4af471575e6cd588c?d=identicon)[johnnickell](/maintainers/johnnickell)

---

Top Contributors

[![johnnickell](https://avatars.githubusercontent.com/u/14907858?v=4)](https://github.com/johnnickell "johnnickell (119 commits)")[![jnickell-code](https://avatars.githubusercontent.com/u/263431892?v=4)](https://github.com/jnickell-code "jnickell-code (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/johnnickell-fight-common/health.svg)

```
[![Health](https://phpackages.com/badges/johnnickell-fight-common/health.svg)](https://phpackages.com/packages/johnnickell-fight-common)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[symfony/symfony

The Symfony PHP framework

31.4k86.9M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.8k19.1M1.7k](/packages/cakephp-cakephp)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M395](/packages/drupal-core-recommended)[windwalker/framework

The next generation PHP framework.

25640.0k1](/packages/windwalker-framework)

PHPackages © 2026

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