PHPackages                             guil95/api-response - 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. guil95/api-response

ActiveLibrary

guil95/api-response
===================

Lib for responses api

0.6.0(7y ago)09Apache-2.0PHPPHP &gt;=7.1.0

Since Feb 21Pushed 7y ago1 watchersCompare

[ Source](https://github.com/guil95/ApiResponse)[ Packagist](https://packagist.org/packages/guil95/api-response)[ RSS](/packages/guil95-api-response/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (5)Used By (0)

ApiResponse
===========

[](#apiresponse)

Use for responses from your API, pass array and status code, get data encoding, header content type and http status code

How to install
==============

[](#how-to-install)

```
composer require guil95/api-response
```

How to use
==========

[](#how-to-use)

```
namespace MyNamespace;

use ApiResponse\Response\ApiResponse;

class MyClass{
  public function save()
  {
    //process save

    //Return json
    // $dataResponse: can be, string, array or object (show only public attributes)
    ApiResponse::json([
      'data' => $dataResponse,
      'message' => 'Persist object!'
    ], ApiResponse::HTTP_CREATED);

    //Return xml
    /**
     * @param array $data
     * @param int $status
     * @param string|null $root
     */
    ApiResponse::xml([
      'data' => $dataResponse,
      'message' => 'Persist object!'
    ],ApiResponse::HTTP_CREATED,
    'root');
  }
}
```

Status code available
=====================

[](#status-code-available)

In the ApiResponse class, there are several consts for defining status code, listed below:

```
HTTP_CONTINUE = 100;
HTTP_SWITCHING_PROTOCOLS = 101;
HTTP_PROCESSING = 102;
HTTP_EARLY_HINTS = 103;
HTTP_OK = 200;
HTTP_CREATED = 201;
HTTP_ACCEPTED = 202;
HTTP_NON_AUTHORITATIVE_INFORMATION = 203;
HTTP_NO_CONTENT = 204;
HTTP_RESET_CONTENT = 205;
HTTP_PARTIAL_CONTENT = 206;
HTTP_MULTI_STATUS = 207;
HTTP_ALREADY_REPORTED = 208;
HTTP_IM_USED = 226;
HTTP_MULTIPLE_CHOICES = 300;
HTTP_MOVED_PERMANENTLY = 301;
HTTP_FOUND = 302;
HTTP_SEE_OTHER = 303;
HTTP_NOT_MODIFIED = 304;
HTTP_USE_PROXY = 305;
HTTP_RESERVED = 306;
HTTP_TEMPORARY_REDIRECT = 307;
HTTP_PERMANENTLY_REDIRECT = 308;
HTTP_BAD_REQUEST = 400;
HTTP_UNAUTHORIZED = 401;
HTTP_PAYMENT_REQUIRED = 402;
HTTP_FORBIDDEN = 403;
HTTP_NOT_FOUND = 404;
HTTP_METHOD_NOT_ALLOWED = 405;
HTTP_NOT_ACCEPTABLE = 406;
HTTP_PROXY_AUTHENTICATION_REQUIRED = 407;
HTTP_REQUEST_TIMEOUT = 408;
HTTP_CONFLICT = 409;
HTTP_GONE = 410;
HTTP_LENGTH_REQUIRED = 411;
HTTP_PRECONDITION_FAILED = 412;
HTTP_REQUEST_ENTITY_TOO_LARGE = 413;
HTTP_REQUEST_URI_TOO_LONG = 414;
HTTP_UNSUPPORTED_MEDIA_TYPE = 415;
HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
HTTP_EXPECTATION_FAILED = 417;
HTTP_I_AM_A_TEAPOT = 418;
HTTP_MISDIRECTED_REQUEST = 421;
HTTP_UNPROCESSABLE_ENTITY = 422;
HTTP_LOCKED = 423;
HTTP_FAILED_DEPENDENCY = 424;

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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.

###  Release Activity

Cadence

Every ~20 days

Total

4

Last Release

2574d ago

### Community

Maintainers

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

---

Top Contributors

[![guil95](https://avatars.githubusercontent.com/u/12828803?v=4)](https://github.com/guil95 "guil95 (27 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/guil95-api-response/health.svg)

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

###  Alternatives

[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[saloonphp/xml-wrangler

Easily Read &amp; Write XML in PHP

4222.3M21](/packages/saloonphp-xml-wrangler)[mtownsend/response-xml

The missing XML support for Laravel's Response class.

1041.2M3](/packages/mtownsend-response-xml)[illuminated/helper-functions

Laravel-specific and pure PHP Helper Functions.

107586.6k7](/packages/illuminated-helper-functions)[mezzio/mezzio-problem-details

Problem Details for PSR-7 HTTP APIs addressing the RFC 7807 standard

271.1M24](/packages/mezzio-mezzio-problem-details)[adamstipak/webpay-php

GP Webpay API Wrapper

45167.3k](/packages/adamstipak-webpay-php)

PHPackages © 2026

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