1. Go to this page and download the library: Download larahub/api-response-kit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
larahub / api-response-kit example snippets
// Controller action — no changes needed
return User::query()->latest()->paginate();
// Default per_page comes from config (default: 10)
return User::query()->latest()->paginate();
// Developer-defined per_page
return User::query()->latest()->paginate(15);
// Cursor pagination is also supported
return User::query()->latest()->cursorPaginate(10);
use LaraHub\ApiResponseKit\Facades\ApiResponseKit;
return ApiResponseKit::paginated(
User::query()->latest()->paginate(15),
'Users fetched successfully'
);
// Returns the value of pagination.per_page (default: 10)
return ApiResponseKit::paginated(
User::query()->latest()->paginate(ApiResponseKit::perPage())
);