PHPackages                             los/api-problem - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. los/api-problem

ActiveLibrary[HTTP &amp; Networking](/categories/http)

los/api-problem
===============

PHP middleware that returns a json formatted response in case of error

2.0.0(9y ago)518.0k2MITPHPPHP ^7.0 || ^7.1

Since Nov 22Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Lansoweb/api-problem)[ Packagist](https://packagist.org/packages/los/api-problem)[ Docs](https://github.com/lansoweb/api-problem)[ RSS](/packages/los-api-problem/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (8)Versions (9)Used By (0)

Api Problem Middleware for PHP
==============================

[](#api-problem-middleware-for-php)

This middleware returns a formatted json in case of error. It's inspired on the [ApiProblem](https://github.com/zfcampus/zf-api-problem) library, but with fewer dependencies.

Usage
-----

[](#usage)

Just add the middleware as the last in your application.

For example:

```
$app->pipe(new \LosMiddleware\ApiProblem\ApiProblem());
```

It will return:

```
{
  "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
  "title": "Method Not Allowed",
  "status": 405,
  "detail": "error",
  "code": "14868ef1-7ef4-4feb-a7ae-9a12c9097375"
}

```

### Zend Expressive

[](#zend-expressive)

If you are using [expressive-skeleton](https://github.com/zendframework/zend-expressive-skeleton), you can copy `config/los-api-problem.global.php.dist` to `config/autoload/los-api-problem.global.php`.

It uses the FinalHandler feature from Expressive. If you prefer to use other FinalHandler, you can manually add this middleware:

```
return [
    'dependencies' => [
        'invokables' => [
            LosMiddleware\ApiProblem\ApiProblem::class => LosMiddleware\ApiProblem\ApiProblem::class,
        ],
    ],
    'middleware_pipeline' => [
        'error' => [
            'middleware' => [
                LosMiddleware\ApiProblem\ApiProblem::class,
            ]
            'error' => true,
        ],
    ],
];
```

But 404 errors will not be handled but this, only by the FinalHandler.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 91.3% 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 ~80 days

Recently: every ~56 days

Total

7

Last Release

3381d ago

Major Versions

0.9.0 → 1.0.12016-08-05

1.0.4 → 2.0.02017-03-20

PHP version history (3 changes)0.9.0PHP ^5.5|^7.0

1.0.1PHP ^7.0

2.0.0PHP ^7.0 || ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b54dffc1ebcb317a0cf825a781ab6c5f30980e9abd0d0a3f9c68830cb05c014?d=identicon)[Lansoweb](/maintainers/Lansoweb)

---

Top Contributors

[![Lansoweb](https://avatars.githubusercontent.com/u/2109813?v=4)](https://github.com/Lansoweb "Lansoweb (21 commits)")[![harikt](https://avatars.githubusercontent.com/u/120454?v=4)](https://github.com/harikt "harikt (1 commits)")[![smartang](https://avatars.githubusercontent.com/u/10196183?v=4)](https://github.com/smartang "smartang (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/los-api-problem/health.svg)

```
[![Health](https://phpackages.com/badges/los-api-problem/health.svg)](https://phpackages.com/packages/los-api-problem)
```

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.1B3.7k](/packages/guzzlehttp-psr7)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[symfony/psr-http-message-bridge

PSR HTTP message bridge

1.3k312.3M929](/packages/symfony-psr-http-message-bridge)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35729.6k2](/packages/telnyx-telnyx-php)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

185671.3k41](/packages/laudis-neo4j-php-client)

PHPackages © 2026

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