1. Go to this page and download the library: Download rozbehsharahi/fhp-rest-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/ */
rozbehsharahi / fhp-rest-api example snippets
use Fhp\Rest\Api;
use Fhp\Rest\Repository\JsonRepository;
use Fhp\Rest\Controller\FlexEntityController;
te()
->activateEntity('post', FlexEntityController::class) // <-- use singular entity name
->run();
use Fhp\Rest\Api;
use Fhp\Rest\Repository\JsonRepository;
. '/database/');
// Api call here
Api::create()
->activateEntity(My\Example\Page::class)
->run();
namespace My\Example;
/**
* My Entity class
*
* @class Page
*/
class Page
{
/**
* @Fhp\Rest\PropertyType\StringType
*/
protected $id;
/**
* @Fhp\Rest\PropertyType\StringType
*/
protected $url;
public function getId() { return $this->id; }
public function setId($id) { $this->id = $id; return $this; }
public function getUrl() { return $this->url; }
public function setUrl($url) { $this->url = $url; return $this; }
}