siam401 / api-utils
A Laravel package for file uploads.
v1.0.0
2025-05-24 06:01 UTC
README
A simple Laravel helper to standardize API JSON responses.
📦 Installation
composer require siam401/api-utils
🚀 Usage
Import the class:
use Siam401\ApiUtils\ApiUtil;
✅ Success Response
return ApiUtil::success('Fetched successfully', $data);
❌ Failure Response
return ApiUtil::failure('Something went wrong', 400, ['field' => 'error']);
💥 Crash Response
return ApiUtil::crash('Unexpected system error', 500, ['exception' => $e->getMessage()]);
🔍 Not Found Response
return ApiUtil::notFound('Record not found');
📁 Response Format
All responses follow a consistent structure:
{ "message": "Description", "contents": {...} }
🛠️ Requirements
- PHP ^8.0
- Laravel 9 or 10
📄 License
This package is open-source software licensed under the MIT license.