Download the PHP package sm-sandy/api-response without Composer
On this page you can find all versions of the php package sm-sandy/api-response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sm-sandy/api-response
More information about sm-sandy/api-response
Files in sm-sandy/api-response
Package api-response
Short Description The ApiResponse package is a simple yet powerful Laravel package designed to streamline the process of formatting API responses. It provides a convenient way to structure and return JSON responses in a consistent format for both success and error scenarios.
License MIT
Homepage https://github.com/sm-sandy/api-response
Informations about the package api-response
Package Name: sm-sandy/api-response
Description:
Introducing the ApiResponse package - an easy-to-use and powerful solution to format API responses. Are you tired of spending endless hours formatting API responses? Look no further than the ApiResponse package. Our simple yet powerful package streamlines the process, providing you with an easy way to create consistent and well-structured JSON responses for various HTTP status codes. Say goodbye to inconsistent and poorly formatted responses and hello to clarity and maintainability in your API codebase. Don't wait any longer. Try the ApiResponse package today and start simplifying your API response formatting process.
Key Features:
- Structured Responses:
- Easily generate responses for common HTTP status codes (2xx, 4xx, 5xx).
- Maintain a consistent response structure across your API.
-
Customization:
- Customize success responses with data, messages, and status codes.
- Provide custom error messages for client and server error responses.
- Default Messages:
- Utilize default messages for common scenarios (e.g., "Resource created successfully," "Internal server error").
-
Configurability:
- Configure default success and error messages via a configuration file for quick adjustments.
- JSON Format:
- All responses are automatically formatted as JSON, ensuring compatibility with modern API standards.
Installation:
- Install the package via Composer:
Usage Example :
- custom:
- ApiResponse::custom(data,message,statusCode);
-
success:
- ApiResponse::success(data,message);
-
created:
- ApiResponse::created(data,message);
-
noContent:
- ApiResponse::noContent();
-
badRequest:
- ApiResponse::badRequest(message);
-
unauthorized:
- ApiResponse::unauthorized(message);
-
forbidden:
- ApiResponse::forbidden(message);
-
notFound:
- ApiResponse::notFound(message);
-
error:
- ApiResponse::error(message);
- Example of laravel controller
License
This package is open-source software licensed under the MIT license.
Contribution
Contributions are welcome! Please feel free to submit issues or pull requests.
Author
Md. Sakwat Minar Sandy
Acknowledgments
Inspired by the need for consistent API responses in Laravel applications.