A Laravel package providing helper functions for streamlined API development. Simplify response handling and enhance the structure of your APIs.
Install the package via Composer:
composer require decodeblock/api-utilityUsing 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.
Run tests using:
composer testDetailed changes for each release are documented in the CHANGELOG.
We welcome contributions! Please see the CONTRIBUTING guide for details.
This package is licensed under the MIT License.