1. Go to this page and download the library: Download skrip42/api-skeleton 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/ */
skrip42 / api-skeleton example snippets
/** in you controller */
class CustomController extends AbstractApiController //extends AbstractApiController
{
public function sameMethod() : Response
{
...
//use api(mixed $data, array $meta = []) method to serialize response
return $this->api($dataOrEntity);
}
...
//in you entity/DOT class
/** @Groups("groupName") */
private $field; //add annotation to filed
/** @Groups("groupName") */
public function GetField(): fieldtype //or to you public method
//in you controller
return $this->api(
$dataOrEntity,
[
'groups' => 'groupName'
]
);