siam401/api-utils

A Laravel package for file uploads.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/siam401/api-utils

v1.0.0 2025-05-24 06:01 UTC

This package is auto-updated.

Last update: 2025-09-24 06:43:39 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.