bootiq / service-layer
B!Q Common service layer
Installs: 24 007
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 3
Open Issues: 0
Requires
- php: ^7.0 || ^8.0
- ext-hash: >=1
- ext-json: >=1.3.7
- guzzlehttp/guzzle: ~6.0|~7.0
- psr/log: ~1.0
- psr/simple-cache: ^1.0
Requires (Dev)
- php-parallel-lint/php-console-color: ^0.2.0
- php-parallel-lint/php-console-highlighter: ^0.4.0
- php-parallel-lint/php-parallel-lint: ^1.2
- phpmd/phpmd: ^2.8
- phpstan/phpstan: ^0.8.5
- phpunit/phpunit: ^6.3
- sebastian/phpcpd: ^3.0
- slevomat/coding-standard: ^4.0
- squizlabs/php_codesniffer: ^3.1
This package is not auto-updated.
Last update: 2025-03-26 21:09:36 UTC
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.