**# Snype API Response
A lightweight Laravel package for consistent and elegant JSON API responses. Simplify your controllers with ApiResponse::success() and ApiResponse::error() methods for structured and reusable response formats.
You can install the package via Composer:
composer require snype/api-responseUse the ApiResponse::success() method to return a successful response.
use Snype\ApiResponse\ApiResponse;
public function index()
{
$data = ['message' => 'Data retrieved successfully'];
return ApiResponse::success($data, 'Success', 200);
}This will return a structured JSON response with a success status.
Use the ApiResponse::error() method to return an error response.
use Snype\ApiResponse\ApiResponse;
public function store(Request $request)
{
// Assuming validation fails
$errors = ['field' => 'This field is required'];
return ApiResponse::error($errors, 'Validation Error', 422);
}This will return a structured JSON response with an error status.
You can easily customize the success and error response structure by extending the ApiResponse class.
- PHP 8.0 or higher
- Laravel 9.x or 10.x
This package is licensed under the MIT License. **