Search by

pharaonic / laravel-api-response

Pharaonic

Consistent Laravel API responses: one envelope for success and error responses, resources and every paginator, with profiles, notifications, request IDs and opt-in exception rendering.

13.2.0 2026-11-26 15:17 UTC

README

PHP Version : 8.3 | 8.4 | 8.5 Laravel Version : 13.x License Build
Source Packagist Version Packagist Downloads AI Ready: Laravel Boost

One consistent envelope for Laravel API responses: success and error responses, resources and every paginator, with profiles, notifications, request IDs and opt-in exception rendering.


Installation

composer require pharaonic/laravel-api-response

The service provider is registered automatically. Publish the configuration when you need to change it:

php artisan vendor:publish --tag=api-response-config

Messages follow the application locale (English and Arabic included). Publish them to change a line or add a language:

php artisan vendor:publish --tag=api-response-translations

Usage

use App\Http\Resources\PostResource;
use App\Models\Post;
use Pharaonic\Laravel\ApiResponse\Response;

class PostController
{
    public function index()
    {
        return Response::success(PostResource::collection(Post::query()->paginate(15)))
            ->message('Posts retrieved.')
            ->notify('Posts loaded.', 'success', title: 'Posts');
    }

    public function show($id)
    {
        return Response::error('Post not found.', 404);
    }
}

Documentation

Full documentation: Laravel API Response Documentation.

Support & Security

See SUPPORT.md and SECURITY.md. Contributions are welcome; see CONTRIBUTING.md.

License

MIT. See LICENSE.