PHP code example of signnow / rest-entity-manager
1. Go to this page and download the library: Download signnow/rest-entity-manager 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/ */
signnow / rest-entity-manager example snippets
use Doctrine\Common\Annotations\AnnotationRegistry;
use JMS\Serializer\Annotation as Serializer;
use SignNow\Rest\EntityManager\Annotation\HttpEntity;
use SignNow\Rest\Entity\Entity;
use SignNow\Rest\Factories\ClientFactory;
use SignNow\Rest\Factories\EntityManagerFactory;
/**
* Class User
*
* @HttpEntity("users/{user}")
*/
class User extends Entity
{
/**
* @var int
* @Serializer\Type("int")
*/
private $id;
/**
* @var string
* @Serializer\Type("string")
*/
private $name;
/**
* @return int
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
}
$clientFactory = new ClientFactory(['base_uri' => 'https://api.github.com']);
$entityManager = (new EntityManagerFactory($clientFactory))->create();
/** @var User $user */
$user = $entityManager->get(User::class, ['user' => 'codeception']);
echo sprintf('Id: %s; Name: %s.', $user->getId(), $user->getName());