PHPackages                             kairos-project/api-formatter - 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. [API Development](/categories/api)
4. /
5. kairos-project/api-formatter

ActiveLibrary[API Development](/categories/api)

kairos-project/api-formatter
============================

The API response formatter component for the Kairos API project part.

05PHP

Since Aug 25Pushed 7y ago1 watchersCompare

[ Source](https://github.com/kairosProject/ApiFormatter)[ Packagist](https://packagist.org/packages/kairos-project/api-formatter)[ RSS](/packages/kairos-project-api-formatter/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

ApiFormatter
============

[](#apiformatter)

The API response formatter component for the Kairos API project part.

1) Subject
----------

[](#1--subject)

The formatter part of the API is in charge of the response creation. It handles the data preformatted by the other parts and inserts them in a specific format inside a PSR response.

The component will use the event dispatching methodology to perform a set of response building logic, such as data formatting, header resolution and so on.

2) Class architecture
---------------------

[](#2-class-architecture)

The formatter will provide a base class to perform the build logic.

Three additional components are designed to provide a logic footprint of the feature. These components are:

- ResponseFactory: used to create a new response instance
- BodyFormatter: used to perform the main body formatting
- HeaderFormatter: used to produce the header assignment

3) Dependency description and use into the element
--------------------------------------------------

[](#3-dependency-description-and-use-into-the-element)

A the time of writing, the formatter is designed to have three production dependencies as:

- psr/log
- symfony/event-dispatcher
- kairos-project/api-controller

### 3.1) psr/log

[](#31-psrlog)

The debugging and error retracement in each project parts is currently a fundamental law in development and it's missing is part of the OWASP top ten threats.

As defined by the third PHP standard reference, the logger components have to implement a specific interface. By the way, the logging system will be usable by each existing frameworks.

### 3.2) symfony/event-dispatcher

[](#32-symfonyevent-dispatcher)

The formatting system is designed to be easily extendable and will implement an event dispatching system, allowing the attachment and separation of logic by priority.

### 3.3) kairos-project/api-controller

[](#33-kairos-projectapi-controller)

The API formatter is made to be used by APIs and the generic system into kairos project is the API controller. This system offer access to specialized workflow events.

The formatter will define the controller component as a dependency to make use of the workflow events.

4) Implementation specification
-------------------------------

[](#4-implementation-specification)

The API formatter class itself will provide a response creation workflow. This workflow will consist of a chain of events, each one responsible for a specific creation and formatting part.

The first fired event is the response creation. It will return a response instance in a specific event, realizing the PHP standard recommendation number 7.

The second event is the body formatting. By encoding the initial process response data, this component will create the response body itself, in the expected format.

The third event is the header formatter. This step is used to provide the expected headers, such as content type or content length.

#### 4.1) Dependency injection specification

[](#41-dependency-injection-specification)

The API formatter will receive an instance of event dispatcher as part of the constructor arguments, and a logger instance. The event dispatcher element will be used to dispatch the three events of the formatter. The logger will be used to trace the formatter workflow.

#### 4.2) format method algorithm

[](#42-format-method-algorithm)

The format method is in charge of the dispatching for each of the formatting events.

```
We assume to receive the response event from the parameters.

Dispatch the "create response" event.
Dispatch the "format body" event.
Dispatch the "process header" event.
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12436206?v=4)[cscfa](/maintainers/cscfa)[@cscfa](https://github.com/cscfa)

---

Top Contributors

[![matthieu88160](https://avatars.githubusercontent.com/u/11874266?v=4)](https://github.com/matthieu88160 "matthieu88160 (8 commits)")

### Embed Badge

![Health badge](/badges/kairos-project-api-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/kairos-project-api-formatter/health.svg)](https://phpackages.com/packages/kairos-project-api-formatter)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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