1. Go to this page and download the library: Download matu/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/ */
matu / response example snippets
use Matu\Response\ResponseFactory;
class HelloController
{
public function hello()
{
$data = [
'message'=> 'hello',
'code' => 200
];
return ResponseFactory::make()->withData($data);
}
}
$lists = User::paginate();
return ResponseFactory::make()->collection($lists, new UserTransformer());
$list = User::find(1);
return ResponseFactory::make()->collection($list, new UserTransformer());