Jsonable

Jsonable

Laravel Jsonable Responses & Exceptions.

Moamen Eltouny (Raggi)
PHP Version : >= 8.0 Laravel Version : >= 8.0 License Support
Source Packagist Version Packagist Downloads

Install

Install the latest version using Composer

composer require pharaonic/laravel-jsonable
JSON

Create a new jsonable form request.

php artisan jsonable:request [request-name]

Create a new jsonable resource.

php artisan jsonable:resource [resource-name]

JSON Responses.

json()->success(array $data, ?string $message = null, ?array $extra = [], int $status = 200, array $headers = []);
Json::success(...); // Facade

json()->errors(array $errors, ?string $code, ?string $message = null, ?array $extra = [], int $status = 400, array $headers = []);
Json::errors(...); // Facade

json()->exception(\Throwable $exception, ?string $code = null, ?string $message = null, ?array $extra = [], int $status = 400, array $headers = []);
Json::exception(...); // Facade

Jsonable Exception Handler.

Extends exception handler in ./app/Exceptions/Handler.php

use Pharaonic\Laravel\Jsonable\Exceptions\ExceptionHandler;

class Handler extends ExceptionHandler
{
    ...
}