PHPackages                             eoneopay/apiformats - 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. eoneopay/apiformats

Abandoned → [eonx-com/apiformats](/?search=eonx-com%2Fapiformats)Package[API Development](/categories/api)

eoneopay/apiformats
===================

Package for working with API requests and responses in different formats

v1.0.0(6y ago)32.3k1[7 PRs](https://github.com/loyaltycorp/apiformats/pulls)4BSD-3-ClausePHPPHP &gt;=7.1

Since Jan 29Pushed 5y ago4 watchersCompare

[ Source](https://github.com/loyaltycorp/apiformats)[ Packagist](https://packagist.org/packages/eoneopay/apiformats)[ RSS](/packages/eoneopay-apiformats/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (19)Versions (5)Used By (4)

API Formats
===========

[](#api-formats)

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

[](#installation)

Use [Composer](https://getcomposer.org/) to install the package in your project:

```
composer require eoneopay/apiformats

```

Formats
-------

[](#formats)

By default the package handle **JSON** (application/json) and **XML** (application/xml, text/xml) formats. If you want to handle different formats or want to implement your own **JSON**/**XML** encoding logic, the only thing you need to do is creating your encoder implementing `\EoneoPay\ApiFormats\Interfaces\RequestEncoderInterface` and tell the package to use it, with which Mime types as explained in the [Configuration](#configuration) section.

Integration
-----------

[](#integration)

#### Laravel

[](#laravel)

To integrate the package into your [Laravel](https://laravel.com) or [Lumen](https://lumen.laravel.com)you need to register the following service provider and middleware:

- **ServiceProvider:** `\EoneoPay\ApiFormats\Bridge\Laravel\Providers\ApiFormatsServiceProvider`
- **Middleware:** `\EoneoPay\ApiFormats\Bridge\Laravel\Middlewares\ApiFormatsMiddleware`

That's it! Your application is now able to easily receive requests and generate responses in several formats.

###### Formatted Api Response

[](#formatted-api-response)

If you want to customise the generated response as its status code or headers without handling body encoding yourself, the package provides the `\EoneoPay\ApiFormats\Bridge\Laravel\Responses\FormattedApiResponse`object you can return from your controllers/middlewares. The `FormattedApiResponse` accept three parameters through its constructor as following:

- **$content (mixed):** array or object able to be cast as an array
- **$statusCode (int):** status code of response, default as 200
- **$headers (array):** headers of response, default as empty array

Configuration
-------------

[](#configuration)

The philosophy of the package is to map encoders to a list of MIME types that they can handle through an array as following:

```
$formats = [
     => [, , ...]
];
```

Each MIME type can be the exact name as `application/json` or a [Regex](http://php.net/manual/en/reference.pcre.pattern.syntax.php)used to match multiple MIME types as `application/vnd.eoneopay.v[0-9]+\+json`.

#### Laravel

[](#laravel-1)

To configure supported formats in your application, create a `api-formats.php` config file with a `formats`array using the encoders class as key and array of associated Mime types as value:

```
// config/api-formats.php

return [
    'formats' => [
        JsonRequestEncoder::class => ['application/json'],
        XmlRequestEncoder::class => ['(application|text)/xml'],
        YourCustomerEncoder::class => ['you-custom-mime-type']
    ]
];
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

2499d ago

### Community

Maintainers

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

---

Top Contributors

[![merk](https://avatars.githubusercontent.com/u/278097?v=4)](https://github.com/merk "merk (18 commits)")[![natepage](https://avatars.githubusercontent.com/u/11576446?v=4)](https://github.com/natepage "natepage (12 commits)")[![dextercampos](https://avatars.githubusercontent.com/u/27075066?v=4)](https://github.com/dextercampos "dextercampos (6 commits)")[![sjdaws](https://avatars.githubusercontent.com/u/659316?v=4)](https://github.com/sjdaws "sjdaws (4 commits)")[![rashmitsingh](https://avatars.githubusercontent.com/u/47509325?v=4)](https://github.com/rashmitsingh "rashmitsingh (1 commits)")

---

Tags

libraryapiformatseoneopay

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/eoneopay-apiformats/health.svg)

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

###  Alternatives

[spatie/laravel-fractal

An easy to use Fractal integration for Laravel applications

1.9k15.1M99](/packages/spatie-laravel-fractal)[yajra/laravel-datatables-fractal

Laravel DataTables Fractal Plugin.

966.9M29](/packages/yajra-laravel-datatables-fractal)[ellipsesynergie/api-response

Simple package to handle response properly in your API

3751.4M20](/packages/ellipsesynergie-api-response)[craftcms/element-api

Create a JSON API for your elements in Craft

503701.3k8](/packages/craftcms-element-api)[knplabs/packagist-api

Packagist API client.

1821.3M34](/packages/knplabs-packagist-api)[tomaj/nette-api

Nette api

36261.8k4](/packages/tomaj-nette-api)

PHPackages © 2026

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