decodeblock / api-utility
Helper functions for api development with laravel
Fund package maintenance!
Decodeblock
Requires
- php: ^8.4||^8.3
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^3.0||^2.0
- pestphp/pest-plugin-arch: ^3.0||^2.0
- pestphp/pest-plugin-laravel: ^3.0||^2.0
This package is auto-updated.
Last update: 2025-05-12 10:42:29 UTC
README
A Laravel package providing helper functions for streamlined API development. Simplify response handling and enhance the structure of your APIs.
Installation
Install the package via Composer:
composer require decodeblock/api-utility
Usage
Example
Using the ApiResponder
trait for handling JSON responses:
use Illuminate\Http\Response; use Decodeblock\ApiUtility\Traits\ApiResponder; class YourController extends Controller { use ApiResponder; public function index() { return $this->successResponse("Hello, API Utility", Response::HTTP_OK, null); } }
The ApiResponder
trait provides methods like:
success($message, $code, $data, $metadata = null)
: For successful responses.error($message, $code, $data, $metadata = null)
: For error responses.
Testing
Run tests using:
composer test
Changelog
Detailed changes for each release are documented in the CHANGELOG.
Contributing
We welcome contributions! Please see the CONTRIBUTING guide for details.
Credits
License
This package is licensed under the MIT License.