Download the PHP package larahub/api-response-kit without Composer

On this page you can find all versions of the php package larahub/api-response-kit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package api-response-kit

LaraHub API Response Kit

Vendor: LaraHub | Domain: larahub.io | Package: larahub/api-response-kit

A Laravel package to standardize API responses, errors, and validation outputs across Laravel applications.

Why


Features

Feature Description
Automatic response formatting Wraps controller return values (arrays, models, collections) into standard JSON
Pagination support Auto-detects paginate() / cursorPaginate() results and moves pagination metadata into meta.pagination
Global error handling Converts exceptions into standardized JSON error responses (404, 403, 401, 500, etc.)
Validation error standardization Formats Laravel validation errors into a clean, predictable structure
Configurable response schema Customize response keys via config file
Request ID generation Unique request ID (LH-XXXXXX) per request for debugging/logging
Facade support Manual response control when automatic formatting is not needed
Middleware integration Intercepts outgoing responses and applies formatting automatically
Debug mode Full stack traces in dev; sensitive info (SQL, file paths) hidden in production
Custom formatters Define your own response structure via custom formatter classes

Installation

Publish Config

This will publish config/api-response-kit.php.


Response Schema

Success Response

Error Response

Validation Error Response


Basic Usage

When middleware is enabled, normal controller returns are automatically wrapped into the standard response schema.


Pagination

Auto-detection (middleware)

When the middleware is enabled, any paginate() or cursorPaginate() return value is automatically detected and reformatted. No changes needed in the controller:

Paginated response schema

Manual usage (Facade)

Using the config per_page helper

Keep your per-page number in one place — config/api-response-kit.php:

Configuration

Publish the config and adjust the default:

Or set it in .env:


Manual Usage (Facade)


Middleware

The package registers a middleware alias:

Auto-registration is controlled by config keys:


Configuration

Customizing Schema Keys and Defaults

Edit config/api-response-kit.php:

Debug Mode

In APP_DEBUG=true (development): full error details and stack traces are included.
In production: SQL queries, stack traces, and file paths are hidden.

Custom Formatters

You can provide your own formatter classes via config:

Config keys:

For safety/backwards-compatibility, per-type overrides should extend the built-in formatter they replace.


Package Architecture

Folder Structure

Core Components

Component Responsibility
ApiResponseKitServiceProvider Register services, publish config, bind into Laravel container
ApiResponseKitMiddleware Intercept responses, detect type, apply appropriate formatter
SuccessFormatter Format successful responses
ErrorFormatter Format generic errors and HTTP exceptions
ValidationFormatter Format validation error responses
ExceptionFormatter Convert exceptions into standardized JSON errors
ResponseSchema Build final response structure based on config
RequestIdGenerator Generate unique request IDs
ConfigResolver Resolve configuration values dynamically
ApiResponseKit (Facade) Manual response control when automatic formatting is not desired

Testing

The package ships with a PHPUnit test suite powered by Orchestra Testbench, which boots a real Laravel application for each test.

Requirements

Dependency Version
phpunit/phpunit ^10.0 \| ^11.0
orchestra/testbench ^8.0 \| ^9.0 \| ^10.0

Install dev dependencies (first time only):

Run the Test Suite

Or via the composer test script if you add one:

Test Structure

File What it covers
tests/TestCase.php Base class — boots the service provider, registers the facade, enables debug mode
tests/SuccessFormatterTest.php SuccessFormatter, ApiResponseKit::success/created/accepted/noContent/paginated, request ID helpers, data normalisation
tests/ErrorFormatterTest.php ErrorFormatter, ValidationFormatter, ExceptionFormatter, all ApiResponseKit error/HTTP-status helpers
tests/MiddlewareTest.php ApiResponseKitMiddleware — pass-through conditions, success wrapping, pagination detection, error/validation formatting, exception catching

Test Environment

The base TestCase pre-configures the following for every test:

Each test method receives a fresh application instance, so config overrides in one test cannot bleed into another.

Example: Override Config Per Test


Target Users


Roadmap

v2 (Planned)

v3 (Planned)


All versions of api-response-kit with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^10.0|^11.0|^12.0|^13.0|^14.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package larahub/api-response-kit contains the following files

Loading the files please wait ...