Looking to hire Laravel developers? Try LaraJobs
This package is not available.

laravel-api-response maintained by pharaonic

Description
Consistent Laravel API responses: one envelope for data, errors, resources and every paginator, with profiles, notifications, request IDs and opt-in exception rendering.
Last update
2026/11/26 16:18 (dev-develop)
License
Downloads
0

Comments
comments powered by Disqus

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');
    }

    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.