PHP code example of ars / api-responder-laravel

1. Go to this page and download the library: Download ars/api-responder-laravel 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/ */

    

ars / api-responder-laravel example snippets


use Responder;

return Responder::ok($response);
return Responder::setMessage('success')->ok($response);
return Responder::tooManyRequests();
return Responder::notFound();
return Responder::unAuthorized();

$data = $this->repository->paginate();
$links = [
    'next' => $data->nextPageUrl(),
    'prev' => $data->previousPageUrl(),
    'path' => $data->path(),
];
$meta = [
    'total'        => $data->total(),
    'current_page' => $data->currentPage(),
    'per_page'     => $data->perPage(),
];
return Responder::setMeta($meta)->setLinks($links)->ok($data->items());

return Responder::setStatusCode(500)->setMessage($e->getMessage())->respond();