1. Go to this page and download the library: Download i3rror/lapi-response 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/ */
i3rror / lapi-response example snippets
use APIResponseTrait;
use MA\LaravelApiResponse\Traits\APIResponseTrait;
class TestController extends Controller
{
use APIResponseTrait;
public function index()
{
return $this->apiResponse([
'message' => 'Test Message',
'data' => [
[
'id' => 1,
'name' => 'Test Name',
],
[
'id' => 2,
'name' => 'Test Name 2',
],
[
'id' => 3,
'name' => 'Test Name 3',
],
]
]);
}
}
return $this->apiOk("test message");
// Or
return $this->apiResponse("test message");