bootiq/service-layer
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.
bootiq/service-layer 适用场景与选型建议
bootiq/service-layer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24.53k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bootiq/service-layer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bootiq/service-layer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 24.53k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2018-02-09