yasinkose/api-responder

A api responder

v1.0.3 2022-04-24 13:51 UTC

This package is auto-updated.

Last update: 2024-05-11 13:47:02 UTC


README

Packagist Packagist Packagist

Description

A Simple Laravel package built to generate API Respond.

Installation

To get started, Install via composer:

composer require yasinkose/api-responder

Laravel

Register Service Provider

Append the following line to the providers key in config/app.php to register the package:

YasinKose\ApiResponder\ServiceProvider::class,

or if you're using Lumen, Add the following snippet to the bootstrap/app.php file under the providers section as follows:

$app->register(YasinKose\ApiResponder\ServiceProvider::class);

Register Facades

If you're using Laravel, Add ApiResponder Facades to the aliases key:

'Respond' => YasinKose\ApiResponder\Facades\ApiResponder::class,

or if you're using Lumen Add the following snippet to the bootstrap/app.php

class_alias(YasinKose\ApiResponder\Facades\ApiResponder::class, "Respond");

Usage

 Respond::ok(string $message = "OK", $attr = [])
 Respond::unAuthenticated(string $message = "Unauthorized", $errors = [])
 Respond::forbidden(string $message = "Forbidden", $errors = [])
 Respond::error(string $message = null, $errors = [])
 Respond::created($attr = null)
 Respond::failedValidation(string $message = "Unprocessable Entity", $errors = [])
 Respond::noContent(string $message = "No Content", $errors = [])

Security

If you discover any security related issues, please email instead of using the issue tracker.

Contributors ✨

Thanks goes to these people: