PHPackages                             hexcores/api-support - 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. hexcores/api-support

ActiveLibrary[API Development](/categories/api)

hexcores/api-support
====================

Support library for API

05241PHP

Since Oct 2Pushed 10y ago4 watchersCompare

[ Source](https://github.com/hexcores/api-support)[ Packagist](https://packagist.org/packages/hexcores/api-support)[ RSS](/packages/hexcores-api-support/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Support Library for Laravel API Application
===========================================

[](#support-library-for-laravel-api-application)

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

[](#installation)

```
$ composer require hexcores/api-support

```

Response
--------

[](#response)

API Support have totally 4 methods for json response. Avaliable methods are -

- Response::ok($data, array $headers = \[\])
- Response::missing($message = null, array $headers = \[\])
- Response::error($message, $status = 500, array $headers = \[\])
- Response::unauthorized($message = null, array $headers = \[\])

Example -

```
use Hexcores\Api\Facades\Response as ApiResponse;

class UserApiController extends Controller
{
	public function create()
	{
		if ( ! User::can('create'))
		{
			// User has not permission to create new record,
			// So response unauthorized with status 401
			return ApiResponse::unauthorized();
		}

		if ( $user = User::create(Input::all()))
		{
			return ApiResponse::ok($user);
		}

		// User creation has a problem,
		// So response error with status 500
		return ApiResponse::error('User creationo is fail');
	}

	public function show($id)
	{
		$user = User::find($id);

		if ( is_null($user))
		{
			return ApiResponse::missing();
		}

		return ApiResponse::ok($user);
	}
}
```

You can use helper functions for each response.

- response\_ok()
- response\_missing()
- response\_error()
- response\_unauthorized()

Middleware
----------

[](#middleware)

- `VerifyApiRequestHeader`

#### VerifyApiRequestHeader

[](#verifyapirequestheader)

VerifyApiRequestHeader middleware is used for api request access checking. You need to pass `X-API-KEY` and `X-API-SECRET` headers for reuqest.

*Note: Add `X-API-KEY` and `X-API-SECRET` at `.env` file*

If you want to add multiple key, use comma for key string from `.env` file.

Example :

```
X-API-KEY=first_key,second_key,third_key
X-API-SECRET=first_secret,second_secret,third_secret

```

Key Generator
-------------

[](#key-generator)

You can use artisan command to generate new key.

Command usage -

Generate new keys and added at .env file

```
php artisan api:key

```

Show current register keys from .env file.

```
php artisan api:key --current

```

Print only the new keys

```
php artisan api:key --print

```

Replace new keys with current register keys from .env file

```
php artisan api:key --replace

```

Add artisan command in `app/console/Kernel.php`

```
protected $commands = [
    \App\Console\Commands\Inspire::class,
    // Other commands.
	Hexcores\Api\Console\ApiKeyGenerate,
];

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.2% 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://www.gravatar.com/avatar/29fb608c623105faf35af0f3e476475691ae2ae377c55f1ae62fae9e959a8848?d=identicon)[nyanlynnhtut](/maintainers/nyanlynnhtut)

---

Top Contributors

[![nyanlynnhtut](https://avatars.githubusercontent.com/u/1456363?v=4)](https://github.com/nyanlynnhtut "nyanlynnhtut (20 commits)")[![Mr-Zer0](https://avatars.githubusercontent.com/u/2142972?v=4)](https://github.com/Mr-Zer0 "Mr-Zer0 (1 commits)")

### Embed Badge

![Health badge](/badges/hexcores-api-support/health.svg)

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

###  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)[facebook/php-business-sdk

PHP SDK for Facebook Business

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

PHP wrapper for the Meilisearch API

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

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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