Download the PHP package libinkk/api-starter without Composer

On this page you can find all versions of the php package libinkk/api-starter. 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-starter

libinkk/api-starter

A production-ready API foundation for Laravel applications with standardized responses, filtering, sorting, searching, pagination, sparse fields, relationship includes, validation, exception handling, request IDs, error codes, localization, versioning, and Artisan tooling.

It extends Laravel with opinionated best practices. It does not replace Laravel.


Table of contents


Requirements

Requirement Version
PHP 8.1+ (8.2, 8.3, 8.4 supported)
Laravel 9, 10, 11, 12, 13

Installation

Publish config and language files:

Or publish manually:

Run the doctor to verify setup:

Register middleware (recommended)

In Laravel 11+ (bootstrap/app.php):

Or use aliases on specific routes:

Aliases registered by the package:

Alias Class
api.performance MeasurePerformance
api.request-id AssignRequestId
api.locale SetLocale
api.version SetApiVersion

Quick start

Example request:


Response envelope

Success

Error

Paginated responses automatically fill meta (current page, last page, total, per page) and links (first, last, prev, next).

Optional timestamp can be enabled in config:


Api facade helpers

Method reference

Method HTTP status Purpose
success($data, $message, $status = 200, $meta, $links) 200 (default) Generic success
created($data, $message, $meta) 201 Resource created
updated($data, $message, $meta) 200 Resource updated
deleted($message, $meta) 200 Resource deleted
validation($errors, $message, $status = 422, $meta) 422 Validation failure
error($message, $status, $errors, $meta, $errorCode) 400 (default) Generic error

Laravel API Resources and paginators are supported as $data.


Exception handling

When enabled, API requests (Accept: application/json, or paths under /api/*) receive the package envelope automatically.

Exception Status Error code
ValidationException 422 VALIDATION_FAILED
ModelNotFoundException 404 MODEL_NOT_FOUND
AuthenticationException 401 UNAUTHENTICATED
AuthorizationException 403 FORBIDDEN
NotFoundHttpException 404 ROUTE_NOT_FOUND
QueryException 500 QUERY_EXCEPTION
Other HTTP exceptions varies HTTP_EXCEPTION
Uncaught errors 500 SERVER_ERROR

Custom API exceptions

Toggle with:

Set 'debug' => true (or API_STARTER_DEBUG=true) to expose detailed exception meta in development.


Validation responses

Form request / validator failures are converted to:

You can also return validation manually:


ApiQuery tutorial

ApiQuery is an allowlist-based query pipeline for Eloquent.

Filtering

Query examples

Type Request
Exact ?status=active
Exact (IN) ?status=active,pending
Partial ?name=john
Boolean ?is_active=true
Between ?price=10,100
Date range ?created_at=2024-01-01,2024-12-31
Date from/to ?created_at_from=2024-01-01&created_at_to=2024-12-31

Nested filter keys (optional):

Only allowlisted filters are applied. Unknown query keys are ignored.

Searching

Default driver is SQL LIKE across the given columns (OR).

Custom search driver:

Sorting

Request Meaning
?sort=name Ascending by name
?sort=-created_at Descending by created_at
?sort=name,-price Multiple sorts

Disallowed sort fields are ignored.

Pagination

Also available:

Config defaults:

Helper utilities:

Sparse fields

Reduce payload size by selecting only allowlisted columns.

Notes:

Relationship includes

Eager-load allowlisted relations only (prevents arbitrary relation loading).


Request ID

Middleware api.request-id assigns a unique ID per request.

Useful for debugging, logging, support tickets, and monitoring.


Performance (response time)

Middleware api.performance measures how long the request took and exposes it like 40.12ms.

Output

Header

JSON body

Setup

Register api.performance as the outermost API middleware so timing covers the full request:

Config


Error codes

Stable codes make client-side branching easier.

Built-in codes:

Add custom codes in config:

Prefer language files for localized custom codes:


Localization

Supported locales out of the box:

Code Language
en English
ta Tamil
ml Malayalam
hi Hindi
de German
it Italian
es Spanish
nl Dutch

Set locale via (in order of priority):

  1. Header X-Locale: de
  2. Query ?lang=es
  3. Accept-Language

Success/error messages use:

Publish and customize:

Config:


API versioning

Resolve version from:

  1. Header X-API-Version: v2
  2. Query ?api_version=v2
  3. Path /api/v2/...

Unsupported versions return 400 with UNSUPPORTED_API_VERSION.

Example route groups:


Middleware

Middleware Alias Responsibility
MeasurePerformance api.performance Measure and expose response time (e.g. 40ms)
AssignRequestId api.request-id Generate/propagate request ID
SetLocale api.locale Set app locale from header/query/Accept-Language
SetApiVersion api.version Resolve and validate API version

Each feature can be disabled independently via features.* flags.


Artisan commands

Generated classes land under app/Filters, app/Sorts, and app/Transformers by default.

Use a custom filter with ApiQuery:


Configuration reference

File: config/api-starter.php

Feature flags

Nothing is mandatory. Disable what you do not need without editing package source.

Query parameters


End-to-end controller tutorial

1. Model

2. Controller

3. Routes

4. Try it

Check the response header and body for timing:


Testing

Package tests use Orchestra Testbench + PHPUnit.

In your app tests you can assert JSON structure:


Out of scope

This package intentionally does not include:

Keep those in dedicated packages or your application.


Design principles


Support


Changelog and license

See CHANGELOG.md for release notes.

Current package version: 1.0.0

Licensed under the MIT license.


All versions of api-starter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1|^8.2|^8.3|^8.4
illuminate/contracts Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/auth Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/pagination Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/routing Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/validation Version ^9.0|^10.0|^11.0|^12.0|^13.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 libinkk/api-starter contains the following files

Loading the files please wait ...