php-extended/php-api-endpoint-http-object

此包已废弃,不再维护。作者建议使用php-extended/php-reifier-object包。

php-extended/php-api-endpoint-http-interface 库的实现


README

php-extended/php-api-endpoint-http-interface 库的实现。

coverage build status

安装

此库的安装通过composer进行,所有类的自动加载通过其自动加载器完成。

  • 他们的网站下载composer.phar
  • 然后运行以下命令将此库作为依赖项安装
  • php composer.phar require php-extended/php-api-endpoint-http-object ^6

基本用法

此库是为了扩展而设计的。HttpEndpoint实现是一个通用的对象,旨在简化转换为真正有用的端点,可能如下所示


use PhpExtended\Endpoint\Endpoint;

class MyEndpoint extends HttpEndpoint
{

	public function getFoo() : Foo
	{
		$stringData = $this->httpGet($this->createUri('https://example.com'));
		return $this->getObject(Foo::class, new CustomDataProvider($stringData));
	}

}

其中getDataProvider()是一个返回数据提供者的方法,该数据提供者获取原始数据,无论是从文件(csv、json、yaml等)还是网络(json api、rest api、xml、解析的html等,甚至是语义格式等)

许可证

MIT(见许可证文件)。