1. Go to this page and download the library: Download everalan/api 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/ */
everalan / api example snippets
use Everalan\Api\Helpers;
class UserController extends Controller
{
use Helpers;
public function show(Request $request, $id)
{
$user = User::findOrFail($id);
return $this->response()->item($user, new UserTransformer());
}
}
$users = User::all();
return $this->response()->collection($users, new UserTransformer());
$users = User::paginate();
return $this->response()->paginator($users, new UserTransformer());