Service Layer vendor, for SOA communication (REST/SOAP).
For installation of Boot!Q Service Layer, use composer:
composer require bootiq/service-layer
Default adapter is GuzzleAdapter, primary for REST communication.
- 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).
To create your own adapter, you have to implement BootIq\ServiceLayer\Adapter\AdapterInterface.
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.
We provide base exception for working with our service layer (BootIq\ServiceLayer\Exception\ServiceLayerException).
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;
}
}
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.