PHPackages                             negartarh/apiwrapper - 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. negartarh/apiwrapper

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

negartarh/apiwrapper
====================

Super Fast, Lightweight, Standard, Octane Compatible, and High Customizable package for Laravel API responses

v0.9.0(12mo ago)383925[1 PRs](https://github.com/negartarh/apiwrapper/pulls)1MITPHPPHP &gt;=8.1CI passing

Since Jan 5Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/negartarh/apiwrapper)[ Packagist](https://packagist.org/packages/negartarh/apiwrapper)[ Docs](https://github.com/negartarh/apiwrapper)[ RSS](/packages/negartarh-apiwrapper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (12)Used By (1)

Laravel Missed API Response Wrapper [![GitHub Repo stars](https://camo.githubusercontent.com/23fd0e1fcf5fb907b9088c54f517d312863bbe257a785b60f8507e69a2cbcf39/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6e65676172746172682f61706977726170706572)](https://camo.githubusercontent.com/23fd0e1fcf5fb907b9088c54f517d312863bbe257a785b60f8507e69a2cbcf39/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6e65676172746172682f61706977726170706572)
======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#laravel-missed-api-response-wrapper-)

### Super Fast | Light Weight | Standard | Octane Compatible | High Customizable

[](#super-fast--light-weight--standard--octane-compatible--high-customizable)

###### Built for Applications Ranging from Small to Large Scale

[](#built-for-applications-ranging-from-small-to-large-scale)

[![Static Badge](https://camo.githubusercontent.com/a62eb9c9081cc43b83aade592dce61b704d60c2130e81038a85105c114ac4793/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617373696e672d74657374733f6c6162656c3d7465737473267374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)](https://camo.githubusercontent.com/a62eb9c9081cc43b83aade592dce61b704d60c2130e81038a85105c114ac4793/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617373696e672d74657374733f6c6162656c3d7465737473267374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)[![Static Badge](https://camo.githubusercontent.com/3530021b78f7067ecbe58870c21466b91f0b9110a9c61ed3c11eb0a30337179f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617373696e672d74657374733f6c6162656c3d504850253230436f6d706f736572267374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)](https://camo.githubusercontent.com/3530021b78f7067ecbe58870c21466b91f0b9110a9c61ed3c11eb0a30337179f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617373696e672d74657374733f6c6162656c3d504850253230436f6d706f736572267374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)[![Static Badge](https://camo.githubusercontent.com/373266bdfa839e2f5048355fac7dcaa209a349005456034b91c2c15318544272/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617373696e672d74657374733f6c6162656c3d436f6461637925323053656375726974792532305363616e267374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)](https://camo.githubusercontent.com/373266bdfa839e2f5048355fac7dcaa209a349005456034b91c2c15318544272/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617373696e672d74657374733f6c6162656c3d436f6461637925323053656375726974792532305363616e267374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)[![GitHub License](https://camo.githubusercontent.com/b70bda352e6946f655c54c55dd55595fbac5b8932060f6d596ed58d224df83c0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)](https://camo.githubusercontent.com/b70bda352e6946f655c54c55dd55595fbac5b8932060f6d596ed58d224df83c0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)[![GitHub Release](https://camo.githubusercontent.com/0539265ce9f245798a0a1fdf596aebcde6f63a4754209855b6140fe0f412913a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)](https://camo.githubusercontent.com/0539265ce9f245798a0a1fdf596aebcde6f63a4754209855b6140fe0f412913a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)[![Packagist Downloads](https://camo.githubusercontent.com/63660b25411f34d81bf5ac04cc2aaf1e2e79b0dda7e0fc6ec13fb6bf89286f43/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)](https://camo.githubusercontent.com/63660b25411f34d81bf5ac04cc2aaf1e2e79b0dda7e0fc6ec13fb6bf89286f43/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d25333838453343)

[![GitHub commit activity](https://camo.githubusercontent.com/39168f43fb92f9563a62e82f0b888c0678973278db1d725f0869a85bf4d4bf57/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6d6d69742d61637469766974792f742f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d253233333033463946)](https://camo.githubusercontent.com/39168f43fb92f9563a62e82f0b888c0678973278db1d725f0869a85bf4d4bf57/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6d6d69742d61637469766974792f742f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d253233333033463946)[![GitHub code size in bytes](https://camo.githubusercontent.com/32b9490e3e6c632f9c74777eecf465bc787e9438dc99951e11f6294bbeea4759/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d253233333033463946)](https://camo.githubusercontent.com/32b9490e3e6c632f9c74777eecf465bc787e9438dc99951e11f6294bbeea4759/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d253233333033463946)[![GitHub repo file or directory count](https://camo.githubusercontent.com/d7514838ad1c9d849f1db9c919591a8a268ba8d68470fbf2a68cc0d2b2e6cc33/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6469726563746f72792d66696c652d636f756e742f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d253233333033463946)](https://camo.githubusercontent.com/d7514838ad1c9d849f1db9c919591a8a268ba8d68470fbf2a68cc0d2b2e6cc33/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6469726563746f72792d66696c652d636f756e742f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d253233333033463946)[![GitHub Discussions](https://camo.githubusercontent.com/e10aefbff7a74b917510e4ebb7e2293c054c481d1676c9bbc37eba83b9f09572/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f64697363757373696f6e732f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d253233333033463946)](https://camo.githubusercontent.com/e10aefbff7a74b917510e4ebb7e2293c054c481d1676c9bbc37eba83b9f09572/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f64697363757373696f6e732f6e65676172746172682f617069777261707065723f7374796c653d666f722d7468652d626164676526636f6c6f723d253233333033463946)[![Languages](https://camo.githubusercontent.com/8415f7e91a0634101e32e346874da344e72cbb3d7fd26365b89dc062e578f07c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f30342d6c616e6775616765733f6c6162656c3d6c616e677561676573267374796c653d666f722d7468652d626164676526636f6c6f723d253233333033463946)](https://camo.githubusercontent.com/8415f7e91a0634101e32e346874da344e72cbb3d7fd26365b89dc062e578f07c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f30342d6c616e6775616765733f6c6162656c3d6c616e677561676573267374796c653d666f722d7468652d626164676526636f6c6f723d253233333033463946)

Introduction
------------

[](#introduction)

The **Laravel Missed API Response Wrapper** package is a high-quality and standard package that makes the process of creating and managing standard API responses in Laravel easy. This package is both fast and lightweight, and fully compatible with Laravel Octane, highly customizable, and automatically enables the standardization of all API responses. By using this package, you can easily manage errors and develop standard API services that automatically provide responses according to HTTP and REST standards.

This package is usable anywhere, from validators to controllers and other components, and automatically provides features such as request status, message, errors, and execution time. Additionally, adding custom values to responses or disabling these features is easily achievable.

Using this package guarantees the standardization of API responses, meaning you can continuously and reliably provide high-quality responses that are easily understandable and usable for consumers of your API, while also being fully compliant with standards. All done automatically.

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

[](#installation)

To install Laravel Missed API Response Wrapper, just run the following command:

```
composer require negartarh/apiwrapper
```

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

[](#configuration)

After installing the package, you need to publish its configuration file. To do that, run the following command:

```
php artisan vendor:publish --provider="Negartarh\APIWrapper\APIResponseServiceProvider"
```

This will publish the `apiwrapper.php` configuration file to your config directory and publish localization files to your `languages/vendor/apiwrapper` directory.

Basic usage
-----------

[](#basic-usage)

There are two ways of utilizing the package: using the facade, or using the helper functions. Either way you will get the same result, it is totally up to you.

### Facade

[](#facade)

#### Example 1.

[](#example-1)

```
use Negartarh\APIWrapper\Facades\APIResponse;

...

public function index():\Illuminate\Http\Response
{
    $users = User::latest()->take(10)->get();

    # Alias of
    # return APIResponse::success($users);
    return APIResponse::ok($users);
}
```

### Helper functions

[](#helper-functions)

#### Example 1.

[](#example-1-1)

```
use Negartarh\APIWrapper\Facades\APIResponse;

...

public function index():\Illuminate\Http\Response
{
    $users = User::latest()->take(10)->get();

    return apiwrapper()->ok($users);
    # or
    return api_response()->ok($users);
}
```

The result of the above codes is as follows:

```
{
  "status": 200, // HTTP status code
  "message": "OK", // HTTP message
  "data": [ // Response data
    {
      "id": 1,
      ...
    },
    ...
  ],
  "errors": [], // Errors
  "execution": "13ms", // Serverside exection time
  "version": "3.2.0" // Your application version
}
```

As you can see, the simple output information has been automatically replaced with the classified information suitable for API requests. Look at the output keys, they are all changeable and editable, but before that, it is better to do more research on the package and get acquainted with its more features.

Advanced Usage
--------------

[](#advanced-usage)

### Automatic output based on HTTP standards

[](#automatic-output-based-on-http-standards)

#### Example 1. Storing data

[](#example-1-storing-data)

```
use Illuminate\Support\Facades\Request;
use Negartarh\APIWrapper\Facades\APIResponse;

...

public function create(Request $request):\Illuminate\Http\Response
{
    $user = User::where('email', '=', $request->get('email'))
                  ->firstOrCreate();

    return APIResponse::created($user);
}
```

The result of the above code is as follows:

```
{
  "status": 201, // HTTP status code
  "message": "Created", // HTTP message
  "data": { // Response data
    "id": 1,
    ...
  },
  "errors": [], // Errors
  "execution": "10ms", // Serverside exection time
  "version": "3.2.0" // Your application version
}
```

#### Example 2. No content

[](#example-2-no-content)

```
use Illuminate\Support\Facades\Request;
use Negartarh\APIWrapper\Facades\APIResponse;

...

public function index(Request $request):\Illuminate\Http\Response
{
    $posts = Post::all();

    if(!is_countable($posts) or count($posts) == 0):

        return APIResponse::noContent();

    else:
        ...
}
```

The result of the above code is as follows:

```
{
  "status": 204, // HTTP status code
  "message": "No Content", // HTTP message
  "data": [],
  "errors": [],
  "execution": "10ms",
  "version": "3.2.0"
}
```

#### Example 3. Validating data

[](#example-3-validating-data)

```
use Illuminate\Http\Exceptions\HttpResponseException;
use Negartarh\APIWrapper\Facades\APIResponse;

class ExampleCaptchaRequest extends FormRequest // example rule class
{
    ...

    /**
     * Handle a failed validation attempt.
     *
     * @param Validator $validator
     * @return HttpResponseException
     */
    public function failedValidation(Validator $validator): HttpResponseException
    {
        # based on RFC: 4918
        return APIResponse::unprocessableEntity($validator->errors());
    }
}
```

The result of the above code is as follows:

```
{
  "status": 422, // HTTP status code
  "message": "Unprocessable Entity", // HTTP message
  "errors": {
    "captcha": [
      "The CAPTCHA has expired."
    ]
  },
  "data": [],
  "execution": "41ms",
  "version": "3.2.0"
}
```

Let’s also take a look at the server response and output headers,

[![plot](./src/ScreenShots/Screenshot_1.png)](./src/ScreenShots/Screenshot_1.png)[![plot](./src/ScreenShots/Screenshot_2.png)](./src/ScreenShots/Screenshot_2.png)everything looks great, If it is hard for you to remember the HTTP standards, no problem, pay attention to the next example.

### Alternative method

[](#alternative-method)

#### Example 1. Status method

[](#example-1-status-method)

```
use Illuminate\Http\Exceptions\HttpResponseException;
use Negartarh\APIWrapper\Facades\APIResponse;

class ExampleCaptchaRequest extends FormRequest // example rule class
{
    ...

    /**
     * Handle a failed validation attempt.
     *
     * @param Validator $validator
     * @return HttpResponseException
     */
    public function failedValidation(Validator $validator): HttpResponseException
    {
        return APIResponse::status(413, $validator->errors());
    }
}
```

and the result is:

```
{
  "status": 413,
  "message": "Request Entity Too Large",
  "errors": [
    ...
  ],
  "data": [],
  "execution": "17ms",
  "version": "3.2.0"
}
```

Wait a moment, isn't it better to customize the output message? So pay attention to the following example:

### Customized messages

[](#customized-messages)

#### Example 1.

[](#example-1-2)

```
use Illuminate\Http\Exceptions\HttpResponseException;
use Negartarh\APIWrapper\Facades\APIResponse;

class ExampleAuthenticationRequest extends FormRequest // example rule class
{
    ...

    /**
     * Handle a failed validation attempt.
     *
     * @param Validator $validator
     * @return HttpResponseException
     */
    public function failedValidation(Validator $validator): HttpResponseException
    {
        # Alias of
        # return APIResponse::status(403, $validator->errors(), 'Where are you looking here?');
        retun APIResponse::forbidden($validator->errors(), 'What are you looking for here?');

    }
}
```

and guess the result:

```
{
  "status": 403,
  "message": "What are you looking for here?",
  "errors": {
    ...
  },
  "data": [],
  "execution": "15ms",
  "version": "3.2.0"
}
```

But wait, there is a better solution, why not implement our own team standard? To do this, just add your own standard to the apiwrapper.php file in the config folder of your project and or make changes to it as needed.

### Customized methods

[](#customized-methods)

#### Example 1.

[](#example-1-3)

```
# path/to/project/configuration/dir/apiwrapper.php

return [
    ...
    'methods' => [
        ...
        'accessDenied' => [
            'code' => 403,
            'message' => 'What are you looking for here?',
            'headers' => [
                'Authorization' => 'Failed',
            ],
        ],
```

and easily use the defined method in your project.

```
use Illuminate\Support\Facades\Request;
use Negartarh\APIWrapper\Facades\APIResponse;

...

public function login(Request $request):\Illuminate\Http\Response
{
    $user = User::where('access_token', '=', $request->get('access_token'))
                  ->first();

    if($user == null):
        return APIResponse::accessDenied();
    else:
        ...
}
```

If you pay attention to the above example, you will see that the header value for each status is adjustable, but what to do to adjust it at runtime? To do this, pay attention to the following example:

### Adjustable headers

[](#adjustable-headers)

#### Example 1.

[](#example-1-4)

```
use Illuminate\Support\Facades\Request;
use Negartarh\APIWrapper\Facades\APIResponse;

...

public function login(Request $request):\Illuminate\Http\Response
{
    $user = User::where('access_token', '=', $request->get('access_token'))
                  ->first();

    if($user == null):
        return APIResponse::accessDenied($user, headers: [
                    ...
               ]);
        # or
        return APIResponse::accessDenied($user)
               ->withHeaders([ ... ]);
    else:
        ...
}
```

Localization
------------

[](#localization)

If your API is multilingual, this package is translatable and has been translated into `Persian`, `Arabic` and `Turkish`. To work with translations, refer to the Laravel documents. for more information, pay attention to the next example:

#### Example 1. Localized response

[](#example-1-localized-response)

```
use Negartarh\APIWrapper\Facades\APIResponse;

...
App::setLocale('fa');
...

return APIResponse::insufficientStorage();
```

and the result:

```
{
  "status": 507,
  "message": "فضای ذخیره سازی ناکافی",
  ...
}
```

If you do not need to translate the messages, you can disable it through the configuration file.

#### Example 2. Disabling localization

[](#example-2-disabling-localization)

```
# path/to/project/configuration/dir/apiwrapper.php

return [
    ...
    'localization' => false,
```

Sorting Responses
-----------------

[](#sorting-responses)

If you wish to further standardize your responses, you can sort them alphabetically. You can achieve this by using the 'sort' key in the configuration file. By setting this key to true, your responses will be sorted alphabetically. The default state of this option is false.

#### Example 1. Enabling sorting responses

[](#example-1-enabling-sorting-responses)

```
# path/to/project/configuration/dir/apiwrapper.php

return [
    ...
    'sort' => true,
```

Customizing responses
---------------------

[](#customizing-responses)

To enable, disable or customize default keys in the response, just do it through the configuration file.

#### Example 1. Disabling default keys

[](#example-1-disabling-default-keys)

```
# path/to/project/configuration/dir/apiwrapper.php

return [
    ...
    'fields' => [
        ...
        'execution' => false,
```

#### Example 2. change the algorithm

[](#example-2-change-the-algorithm)

```
# path/to/project/configuration/dir/apiwrapper.php

return [
    ...
    'fields' => [
        ...
        'version' => fn(mixed $content, int $status, string $message) => env('API_VERSION', 'x.x.x'),
        or
        'version' => 'Namespace\Of\Custom\Class::static_method', //recommended
        or
        'version' => 'any_callable_function',
```

You can get more information on this by studying the configuration file.

Changing the default key names
------------------------------

[](#changing-the-default-key-names)

Like the previous examples, to change the default key names in the response, just do it through the configuration file.

#### Example 1.

[](#example-1-5)

```
# path/to/project/configuration/dir/apiwrapper.php

return [
    ...
    'replaces' => [
        ...
        'data' => 'content',
```

result:

```
{
  "status": 200,
  "message": "OK",
  "content": [ // changed from data to content
    {
      "id": 1,
      ...
    },
    ...
  ],
  "errors": [],
  "execution": "7ms",
  "version": "3.2.0"
}
```

Adding custom values
--------------------

[](#adding-custom-values)

To add custom values to the API response, do the following in the configuration file.

#### Example 1.

[](#example-1-6)

```
# path/to/project/configuration/dir/apiwrapper.php

return [
    ...
    'custom_keys'=>[
        'app'=> 'My Wonderful APP',
        ...
        'time'=> fn(mixed $content, int $status, string $message) => \Illuminate\Support\Carbon::now(),
        or
        'time' => 'Namespace\Of\Custom\Class::static_method', //recommended
        or
        'time' => 'any_callable_function',
```

and the result:

```
{
  "status": 200,
  ...
  "app": "My Wonderful APP",
  "time": "2024-01-05T02:42:10.636571Z"
}
```

Hints
-----

[](#hints)

#### Example 1. Real-World software development with axios

[](#example-1-real-world-software-development-with-axios)

###### Back-End:

[](#back-end)

```
# API Login Controller
use Negartarh\APIWrapper\Facades\APIResponse;

...

    public function login(LoginRequest $request):\Illuminate\Http\Response
    {
        ...

        return APIResponse::ok([
                ...
            ]);
    }

# API LoginRequest Form Request
use Negartarh\APIWrapper\Facades\APIResponse;

...

    public function failedValidation(Validator $validator): HttpResponseException
    {
        return APIResponse::unprocessableEntity($validator->errors());
    }
```

###### Front-End:

[](#front-end)

```
let isOnRequest = false;

...

async function submitForm() {

    isOnRequest = true;

    await axios.post('api/login', {
        ...
    })
    .then((response) => {
        // if validation passed, you can get response here
        console.log(response.data)
    }).catch((error)=>{
        // if validation failed, you can catch errors here
        console.log(error.response.data)
    }).finally(()=>{
        isOnRequest = false;
    });
}
```

#### Example 2. Handle 404 status in api responses

[](#example-2-handle-404-status-in-api-responses)

```
# app/Exceptions/Handler.php

class Handler extends ExceptionHandler
{
    ...

        public function register()
        {
            $this->reportable( function ( Throwable $e ) {
                //
            } );

            $this->renderable(function (NotFoundHttpException $e, Request $request) {
                if ($request->is('api/*')):
                    return APIResponse::status(404);
                endif;
            });

        }
```

Built-in methods
----------------

[](#built-in-methods)

In the table below, the predefined methods are given with the HTTP code and message text. All these values are accessible and changeable through the config file.

No.METHODHTTP STATUSMESSAGE\#0ok200OK\#1success200Success\#2created201Created\#3accepted202Accepted\#4nonAuthoritativeInformation203Non Authoritative Information\#5noContent204No Content\#6resetContent205Reset Content\#7partialContent206Partial Content\#8multiStatus207Multi Status\#9alreadyReported208Already Reported\#10imUsed226IM Used\#11multipleChoices300Multiple Choices\#12movedPermanently301Moved Permanently\#13found302Found\#14seeOther303See Other\#15notModified304Not Modified\#16useProxy305Use Proxy\#17temporaryRedirect307Temporary Redirect\#18permanentRedirect308Permanent Redirect\#19badRequest400Bad Request\#20unauthorized401Unauthorized\#21paymentRequired402Payment Required\#22forbidden403Forbidden\#23notFound404Not Found\#24methodNotAllowed405Method Not Allowed\#25notAcceptable406Not Acceptable\#26proxyAuthenticationRequired407Proxy Authentication Required\#27requestTimeout408Request Timeout\#28conflict409Conflict\#29gone410Gone\#30lengthRequired411Length Required\#31preconditionFailed412Precondition Failed\#32requestEntityTooLarge413Request Entity Too Large\#33requestURITooLong414Request URI Too Long\#34unsupportedMediaType415Unsupported Media Type\#35requestedRangeNotSatisfiable416Requested Range Not Satisfiable\#36expectationFailed417Expectation Failed\#37unprocessableEntity422Unprocessable Entity\#38locked423Locked\#39failedDependency424Failed Dependency\#40tooEarly425Too Early\#41upgradeRequired426Upgrade Required\#42preconditionRequired428Precondition Required\#43tooManyRequests429Too Many Requests\#44requestHeaderFieldsTooLarge431Request Header Fields Too Large\#45noResponse444No Response\#46unavailableForLegalReasons451Unavailable For Legal Reasons\#47internalServerError500Internal Server Error\#48notImplemented501Not Implemented\#49badGateway502Bad Gateway\#50serviceUnavailable503Service Unavailable\#51gatewayTimeout504Gateway Timeout\#52httpVersionNotSupported505HTTP Version Not Supported\#53variantAlsoNegotiates506Variant Also Negotiates\#54insufficientStorage507Insufficient Storage\#55loopDetected508Loop Detected\#56notExtended510Not Extended\#57networkAuthenticationRequire511Network Authentication RequireRequirments
-----------

[](#requirments)

- php: &gt;= 8.1
- illuminate/support: \*

Contributing
------------

[](#contributing)

We will be happy if we see PR from you.

License
-------

[](#license)

This is a free package released under the MIT License.

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance71

Regular maintenance activity

Popularity29

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.5% 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 ~49 days

Recently: every ~98 days

Total

11

Last Release

364d ago

### Community

Maintainers

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

---

Top Contributors

[![negartarh](https://avatars.githubusercontent.com/u/65663698?v=4)](https://github.com/negartarh "negartarh (65 commits)")[![dcblogdev](https://avatars.githubusercontent.com/u/1018170?v=4)](https://github.com/dcblogdev "dcblogdev (1 commits)")

---

Tags

apiapi-gatewaylaravellaravel-octaneoctaneresponseresponse-managementrestrestful-apistandard-libraryresponsephpjsonapilaravelrestRESTful APIrestfulrfclaravel responselaravel-octane

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/negartarh-apiwrapper/health.svg)

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

###  Alternatives

[obiefy/api-response

Simple Laravel package to return Json responses.

17324.6k](/packages/obiefy-api-response)[guanguans/laravel-api-response

Normalize and standardize Laravel API response data structure. - 规范化和标准化 Laravel API 响应数据结构。

485.6k](/packages/guanguans-laravel-api-response)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.0k](/packages/ismaeltoe-osms)

PHPackages © 2026

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