1. Go to this page and download the library: Download shalvah/laravel-jsend 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/ */
shalvah / laravel-jsend example snippets
public function create(Request $request)
{
$userData = $request->input('data');
if (empty($userData['email']))
return jsend_fail(['email' => 'Email is '.$e->getMessage());
}
}
class Handler extends ExceptionHandler
{
use Shalvah\LaravelJsend\JsendExceptionFormatter;
// ...
}
return jsend_success([
"id" => 2,
"title" => "New life",
"body" => "Trust me, this is great!"
]);