bootiq/service-layer
最新稳定版本:01.02.00
Composer 安装命令:
composer require bootiq/service-layer
包简介
B!Q Common service layer
README 文档
README
Service Layer vendor, for SOA communication (REST/SOAP).
Installation
For installation of Boot!Q Service Layer, use composer:
composer require bootiq/service-layer
Adapters
BootIq\ServiceLayer\Adapter\GuzzleAdapter
Default adapter is GuzzleAdapter, primary for REST communication.
Configuration
- dependencies
- client - GuzzleHttp\ClientInterface - client for calling requests.
- responseFactory - BootIq\ServiceLayer\Response\ResponseFactoryInterface - response factory for creating specific response.
- urn - URN of API (for example: https://api.bootiq.io).
- timeout - request timeout provided by setTimeout method (default: 10s).
- cache - if you want cache responses, provide your cache service (PSR-16).
- logger - if you want log what is going on in adapter, provide your logger service (PSR-3).
Own adapter
To create your own adapter, you have to implement BootIq\ServiceLayer\Adapter\AdapterInterface.
Enum
Library provides enums:
- BootIq\ServiceLayer\Enum\HttpCode - List of all HTTP codes according to http://www.restapitutorial.com/httpstatuscodes.html.
- BootIq\ServiceLayer\Enum\HttpMethod - List of all available HTTP methods according to http://www.restapitutorial.com/lessons/httpmethods.html.
Exception
We provide base exception for working with our service layer (BootIq\ServiceLayer\Exception\ServiceLayerException).
Requests
Every request which can be called by adapter must implement BootIq\ServiceLayer\Request\RequestInterface.
In BootIq\ServiceLayer\Request namespace are abstract classes for various http methods, for more simple integration with our service layer.
For example:
<?php namespace BootIq\CmsApiVendor\Request\Page; use BootIq\ServiceLayer\Request\GetMethod; class GetPageRequest extends GetMethod { /** * @var int */ private $pageId; /** * GetPageRequest constructor. * @param int $pageId */ public function __construct(int $pageId) { $this->pageId = $pageId; } /** * @return string */ public function getEndpoint(): string { return 'page/' . $this->pageId; } }
Response
Every response returned by adapter must implement BootIq\ServiceLayer\Response\ResponseInterface.
We provide default response object BootIq\ServiceLayer\Response\Response and default response factory BootIq\ServiceLayer\Response\ResponseFactory for faster implementation.
统计信息
- 总下载量: 24.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2018-02-09