Download the PHP package surazdott/api-response without Composer

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

GitHub Workflow Status (main) Latest Version License

Laravel API Response

Laravel API Response package simplifies the process of generating standardized JSON responses in Laravel applications. It provides a consistent and intuitive API through the package, offering a variety of methods to manage different types of HTTP responses effectively.

Installation

Requires PHP 8.1+

To install the package, you can use Composer:

You can publish the config, languages and resources from with the help of command.

Basic usage

After installing the package, you can use the Api facade or helper function to generate JSON responses in your controllers or anywhere within your application. The following methods are available:

Facade

Generates a generic JSON response with facade.

Helper function

Generates a generic JSON response with helper function.

This is the result.

Methods

response

Generates a generic JSON response with a customizable status code.

response(string $message, mixed $data = [], int $status = 200)

success

Method for a successful operation with HTTP status code 200.

success(string $message, mixed $data = [])

paginate

Return for a successful operation with HTTP paginated data.

paginate(string $message, mixed $data = [])

created

Returns a response indicating that a resource has been successfully created with HTTP status code 201.

created(string $message, mixed $data = [])

error

Returns an error response with HTTP status code 4xx.

error(string $message, int $status = 400)

unauthorized

Returns an unauthorized response with HTTP status code 401.

unauthorized(string $message)

forbidden

Returns an unauthorized response with HTTP status code 401.

forbidden(string $message)

notFound

Returns a not found response with HTTP status code 404.

notFound(string $message)

notAllowed

Returns a method not allowed response with HTTP status code 405.

notAllowed(string $message)

validation

Generates a response indicating validation errors with HTTP status code 400.

validation(string $message, mixed $errors = [])

serverError

Returns an error response with HTTP status code 4xx.

serverError(string $message, int $status = 500)

Note: API response messages are predefined and can be changed from parameters or from the language file.

Request Validation

Laravel's request validation can be used for both web and API. You can call the trait

SurazDott\ApiResposne\Concerns\HasApiResponse;

API Exceptions

If you want to throw the custom exceptionl, you can use the following classes:

ApiResponseException(string $message, ?int status)

ApiValidationException(mixed $errors, ?string $message)

Contributing

If you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request. Contributions are welcome!

License

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


All versions of api-response with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
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 surazdott/api-response contains the following files

Loading the files please wait ....