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
Api Response

Api Response Laravel Package

andrey-helldar/api-response

Laravel package for building consistent JSON API responses. It offers convenient helpers for success and error replies, standardizes response structure, status codes, and messages, and helps reduce repetitive boilerplate in controllers and resources.

View on GitHub
Deep Wiki
Context7

Package for standardizing the responses from the API of your Symfony based applications.

Frequently asked questions about Api Response
What is andrey-helldar/api-response used for in a Laravel API?
It is a lightweight presentation-layer package that standardizes the JSON envelope your API returns. Instead of hand-building arrays in every controller, you call a helper or facade to produce a success, error, or exception-style response with a status code, message, and data payload. The goal is that clients always see the same structure, which makes gateways, logging rules, and client SDKs easier to reason about. It does not handle serialization, transport, or domain logic, and it sits alongside Laravel Resources and Sanctum rather than replacing them.
How do I install andrey-helldar/api-response in a Laravel application?
Installation is a single Composer require followed by calling the provided helper or facade from any controller. There is no database, queue, or event integration, so there are no migrations or service providers to wire up beyond normal package discovery. Note that the project has moved to the-dragon-code/api-response for newer major versions, so confirm which package name matches the version you intend to install on Packagist before running Composer.
Do I need to publish a config file to use this package?
No, the package is designed for minimal setup and works out of the box without publishing configuration. Defaults cover the response envelope, status codes, and headers, and you can override status codes, messages, headers, and data per call through the fluent helpers. If you do publish or override config, diff those keys between major versions, because config drift is the most common silent breakage in this class of package.
How do I return success, error, and exception responses from a controller?
Use the fluent helpers for each case: a success helper for normal payloads, an error helper for client or validation failures, and an exception-style helper when you want a consistent shape for failure paths. Each call lets you set the status code, message, and data payload so the envelope stays uniform while the content changes. Because it is just a thin layer over Laravel's response factory, you can adopt it in one controller first and expand incrementally.
Which Laravel and PHP versions does andrey-helldar/api-response support?
The package targets modern Laravel releases, but the exact PHP and Laravel floors depend on the version you install and on its dragon-code/support dependency. Version 10.0.0 is largely a bump of dragon-code/support to 6.0, and that major bump strongly implies raised PHP and Laravel constraints. Always check the composer.json constraints for your pinned framework version and run composer why-not before upgrading.
What changed in v10.0.0 and will upgrading break my API?
The 10.0.0 release carries no functional changelog of its own; it is almost entirely a transitive bump of dragon-code/support to 6.0. That means the breaking potential is inherited from that dependency, including possible removed helper methods or raised version floors, and it is not verifiable from the release notes alone. If any of your own code or other packages also depend on dragon-code/support, the bump forces them to 6.0 as well, which can cascade into a wider upgrade than expected. Pin your current 9.x line first and upgrade on a branch so you can compare behavior.
How should I test API responses before and after upgrading the package?
Capture your current envelope in contract tests before touching the dependency: snapshot the JSON shape for a success response, a validation error, a 404, a 500, and a paginated payload. Upgrade on a branch with composer require the-dragon-code/api-response:^10.0 and run composer why-not to surface constraint conflicts early. Then rerun the same contract tests, because any diff in envelope, status codes, or headers is a consumer-facing breaking change regardless of what the changelog says. Roll out in staging first, service by service, leaving the oldest and most coupled services for last.
Is andrey-helldar/api-response safe for production and how is it maintained?
Architecturally it is low risk: a small surface area, no container gymnastics, and no opinion about your domain layers. The maintenance risk is organizational rather than technical, with a single maintainer and a low-ceremony release process, so bus factor and long-term support guarantees are thin. That is acceptable for a utility but not for something load-bearing without a fallback, since replacing it amounts to writing a handful of response macros. Keep an internal fallback in mind if your API contract depends on it.
Does it work alongside Laravel API Resources, pagination, and Sanctum?
Yes, it sits alongside them rather than competing with them. Resources and paginators produce the data that goes into the envelope, while the package only shapes the outer structure, status code, message, and headers. That makes it useful for versioned public APIs, internal service-to-service endpoints, and BFF layers where several consuming teams rely on a consistent response shape. It adds little value for a single small internal endpoint or a service that already has a strict hand-rolled contract.
What are the alternatives if I only need a few consistent JSON responses?
If your API is small or already has a strict response contract, plain response()->json() calls or a base API controller with your own helper methods may be simpler than adding a dependency. Custom response macros give you most of the same convenience with zero third-party maintenance risk. This package is worth it when envelope consistency matters across many controllers and multiple consuming teams, so weigh that against the cost of tracking an upstream dependency's major releases.
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.
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
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo