Download the PHP package anyo-lab/api-response without Composer

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

Laravel API Response

Latest Version on Packagist Total Downloads License Tests

A comprehensive Laravel package for universal API response and error handling. This package provides a standardized way to format API responses and handle exceptions in Laravel applications with multiple usage patterns and advanced features.

πŸš€ Features

πŸ“‹ Requirements

πŸ”§ Installation

Via Composer

Manual Installation

  1. Clone or download this package
  2. Add to your composer.json:

  3. Run composer update

βš™οΈ Configuration

Publish the configuration file:

This will create config/api-response.php with customizable options.

Production readiness

Before using in a live project:

  1. Set APP_DEBUG=false in .env so error responses never expose stack traces or file paths.
  2. Publish config (optional): php artisan vendor:publish --tag=api-response-config to override messages, structure, or timestamp format.
  3. Override messages in config/api-response.php under messages so all default strings (e.g. "Resource not found") come from one place.
  4. Optional: Enable include_request_id and include_error_codes in config for tracing and machine-readable error codes.

All responses use the same config (structure, timestamp, error codes). ResponseHelper and resources use the same settings as the main ApiResponse service.

Upgrading / Breaking changes

See CHANGELOG.md for full version history.

🎯 Quick Start

Basic Usage

Tip: For testability and flexibility, type-hint ApiResponseContract instead of ApiResponse so you can swap or mock the implementation.

πŸ“– Usage Methods

Method 1: Service Injection

Method 2: Trait Usage

Method 3: Facade Usage

Method 4: Response Macros

Method 5: Global Helper Functions

Method 6: Resource Classes

πŸ“€ Response Methods

Success Responses

Error Responses

πŸ“‹ Response Format

All responses follow this standardized format:

Success Response

Error Response

Pagination Response

πŸ›‘οΈ Exception Handling

The package includes a custom exception handler that automatically formats exceptions for API routes:

Exception Status Code Description
ValidationException 422 Validation errors
AuthenticationException 401 Unauthorized
ModelNotFoundException 404 Not found
NotFoundHttpException 404 Not found
QueryException 500 Server error (with debug info in development)
HttpException Respective HTTP status code

βš™οΈ Configuration Options

Response Structure

Default Messages

Other Options

πŸ”„ Advanced Features

Middleware Support

API Versioning

Response Compression

Performance Monitoring

πŸ§ͺ Testing

πŸ“Š Complete Example

Testing this package

Enterprise & production

For production use, enable request IDs and error codes in config; apply rate limiting and set APP_DEBUG=false.

🀝 Contributing

Please see CONTRIBUTING.md for development setup, code style, and pull request guidelines.

Security

If you discover a security vulnerability, please see SECURITY.md.

Changelog

See CHANGELOG.md for version history.

πŸ“„ License

This package is open-sourced software licensed under the MIT license.

πŸ†˜ Support

πŸ™ Acknowledgments


Laravel API Response – A generic package for standardized API responses.


All versions of api-response with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
illuminate/http Version ^9.0|^10.0|^11.0|^12.0
illuminate/validation Version ^9.0|^10.0|^11.0|^12.0
illuminate/cache Version ^9.0|^10.0|^11.0|^12.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 anyo-lab/api-response contains the following files

Loading the files please wait ...