Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Api Response

Laravel Api Response Laravel Package

kennedy-osaze/laravel-api-response

A Laravel package for consistent, structured API responses. Standardize success and error JSON payloads, reduce repetitive controller code, and keep your API output clean and predictable across your application.

View on GitHub
Deep Wiki
Context7

Renders consistent HTTP JSON responses for API-based projects

Frequently asked questions about Laravel Api Response
What is kennedy-osaze/laravel-api-response used for?
It is a thin Laravel presentation-layer helper for rendering consistent HTTP JSON success and error responses in API-based projects. It is intended to standardize response envelopes, HTTP status codes, and pagination metadata while reducing repetitive controller code. It should stay behind your API layer and should not own domain logic or become the source of truth for your API contract.
How do I install kennedy-osaze/laravel-api-response in Laravel?
Install it with Composer by running composer require kennedy-osaze/laravel-api-response in your Laravel project. Then confirm service-provider auto-discovery, any publishable config, and the exact version constraint in your environment. Because the package is small, install it in a branch and pilot one endpoint group before rolling it out.
Which Laravel and PHP versions does laravel-api-response support?
The published v2.0 release note only states Laravel 10.x support, and the last release was 2023-03-19. The provided context does not list explicit PHP version constraints beyond Laravel 10's requirements. Check the package composer.json and run Composer resolution against your exact Laravel minor and PHP runtime before adopting it.
What do the success and error JSON responses look like?
The package is designed to render consistent JSON envelopes for success and error responses with appropriate HTTP status codes. The exact field names for success, error, validation-error, and pagination payloads are not specified in the provided README excerpt. Inspect the package source or docs and codify the actual schema in contract tests before treating it as your API standard.
Can I customize the API response envelope?
The assessment flags envelope customization as a key question, but the provided context does not confirm a publishable config or override mechanism. If you need custom field names or error taxonomy, wrap the package behind your own response factory instead of forking it. Also verify config-cache behavior if the package publishes a config file.
Does laravel-api-response support pagination metadata?
The package is described as standardizing pagination metadata as part of its API response envelope. The exact metadata keys and compatibility with Laravel paginators and API resources are not confirmed in the excerpt. Test it with your existing paginator classes and assert stable pagination output in contract tests.
How does laravel-api-response handle validation errors?
The package covers error JSON payloads, and the assessment specifically asks about validation-error shapes. The provided context does not document how Laravel FormRequest validation failures are formatted. Test a real validation failure and confirm the response does not leak internals before standardizing it across endpoints.
How should I test API responses from this package?
Add contract tests that assert the exact JSON schema, HTTP status codes, error shapes, and pagination metadata for representative endpoints. Include smoke tests for service-provider auto-discovery and config caching in a Laravel 10 environment. A one-endpoint pilot is low-cost and low-risk because the package is small.
Is laravel-api-response safe for production and actively maintained?
Runtime risk is low for a response-formatting utility, but maintenance and contract risk are moderate because the last release was 2023-03-19 and Laravel 10-only support is the only clear signal. There is limited public signal on maintainer cadence, test coverage, and security posture. Pin the version, track Composer constraints, validate error responses for leaked internals, and require an ADR before broad adoption.
What are alternatives to laravel-api-response, or should I wrap it?
Alternatives include Laravel's built-in response helpers with your own internal envelope or other API response packages. The more important decision is to own a stable internal ApiResponse contract so controllers and domain code do not couple directly to a third-party package. Wrap this package behind that contract, codify the expected schema, and run contract tests before migrating multiple endpoint groups.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect