Download the PHP package creativecrafts/laravel-api-response without Composer

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

Laravel API Response

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Code Coverage Total Downloads

Laravel API Response is a powerful and flexible package that provides a standardized way to structure API responses in Laravel applications. It offers a range of features to enhance your API development experience, including consistent response formatting, conditional responses, pagination support, rate limiting, and more.

Table of Contents

1. [Installation](#installation)
2. [Configuration](#configuration)
3. [Basic Usage](#basic-usage)
4. [Feature](#feature)
    - [Success Response](#success-response)
    - [Error Response](#error-response)
    - [Conditional Response](#conditional-response)
    - [Pagination](#pagination)
    - [Rate Limiting](#rate-limiting)
    - [Response Compression](#response-compression)
    - [Localization](#localization)
    - [HATEOAS Links](#hateoas-links)
    - [Logging](#logging)
5. [Advanced Usage](#advanced-usage)
6. [Testing](#testing)
7. [Changelog](#changelog)
8. [Contributing](#contributing)
9. [Security Vulnerabilities](#security-vulnerabilities)
10. [Credits](#credits)
11. [License](#license)

1. Installation

You can install the package via composer:

2. Configuration

The package comes with a default configuration file that you can publish to your application using the following command:

This will create a laravel-api-response.php file in your config directory. You can customize various aspects of the package behavior in this file.

3. Basic Usage

There are two ways to use the Laravel API Response in your controllers:

Using Dependency Injection

You can inject the LaravelApi class:

Using the Facade

For a more Laravel-like experience, you can use the LaravelApiResponse facade:

4. Feature

The Laravel API Response package provides a range of features to help you build robust and reliable APIs. Here are some of the key features:

Success Responses

To return a success response:

Error Responses

To return an error response:

Conditional Responses

For responses that support caching and conditional requests:

This method automatically handles ETag and Last-Modified headers for efficient caching.

Pagination

The package supports Laravel's pagination:

Rate Limiting

Rate limiting is automatically applied to API routes. You can configure the rate limit in the laravel-api-response.php config file:

Response Compression

Response compression can be enabled or disabled in the config:

Localization

The package supports message localization. Use the localize method to translate messages:

HATEOAS Links

You can include HATEOAS links in your responses:

Logging

API responses are logged to a dedicated channel. You can configure the channel in the config file:

Exception Handling

The package includes a custom exception handler that automatically formats exceptions into consistent API responses. This is enabled by default and can be configured in the config file:

When enabled, the exception handler will automatically catch exceptions and format them into API responses with appropriate status codes. For example:

This ensures consistent error responses across your API without requiring extra code in your controllers.

5. Advanced Usage

The Laravel API Response package provides a range of advanced features to help you build robust and reliable APIs. Here are some of the key features:

Custom Response Structure

You can customize the response structure in the config file:

Filtering Response Fields

You can filter the fields returned in the response:

Custom Status Codes

You can specify custom HTTP status codes for your responses:

Extending with Custom Methods

The LaravelApi class uses Laravel's Macroable trait, allowing you to add custom response methods at runtime:

This makes it easy to extend the package with your own custom response types without modifying the core code.

Version 2: Breaking Changes

Version 2 of the package introduces one breaking change.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-api-response with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3|^8.2
spatie/laravel-package-tools Version ^1.19
illuminate/contracts Version ^12.0|^11.0|^10.0
ext-simplexml Version *
ext-zlib Version *
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 creativecrafts/laravel-api-response contains the following files

Loading the files please wait ...