定制 signnow/rest-entity-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

signnow/rest-entity-manager

最新稳定版本:v2.3.0

Composer 安装命令:

composer require signnow/rest-entity-manager

包简介

Library gives you ability to communicate to REST API within DTO objects

README 文档

README

This project helps to communicate with REST API using DTO objects

Requirements

PHP 7.1 or newer

Installation

The library can be installed using Composer.

composer require signnow/rest-entity-manager

Usage

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());

统计信息

  • 总下载量: 106.39k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-23