1. Go to this page and download the library: Download everycheck/api-rest-utils 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/ */
everycheck / api-rest-utils example snippets
public function getAction($id)
{
$response = new ResponseBuilder($this->get('jms_serializer'));
$entity = $this->getDoctrine()->getManager()->getRepository(Entity::class)->find($id);
if(empty($entity)) return $response->notFound();
return $response->ok($entities);
}
public function getAction($id)
{
$response = new ResponseBuilder($this->get('jms_serializer'));
$entity = $this->getDoctrine()->getManager()->getRepository(Entity::class)->find($id);
if(empty($entity)) return $response->notFound();
return $response->addHeaders('X-something','some-value')->ok($entities);
}