Download the PHP package remessage/client without Composer
On this page you can find all versions of the php package remessage/client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download remessage/client
More information about remessage/client
Files in remessage/client
Package client
Short Description PHP client for Re Message
License Apache-2.0
Homepage https://dev.remessage.ru/packages/client
Informations about the package client
Re Message Client
This package provides an object-oriented client level to interact with Re Message Core. The package architecture inspired by DBAL and Doctrine packages.
Client uses the specific version when sends messages to Core.
Requirements
- PHP 8.1+
- Any
psr/http-client
compatible package to send HTTP requests -
Any
psr/event-dispatcher
compatible packageConfigurator for
symfony/event-dispatcher
included in package
Installation
You will need Composer to install:
composer require remessage/client
Usage
To create an instance of client, you need to choose transport. Now available only HTTP protocol transport. This transport can work with PSR 7, PSR 17, PSR 18 implementation. For example, symfony/http-client
. We will use this package as http client in next examples.
Any transport requires message serializer from remessage/message
package. You can use RM\Standard\Message\Serializer\ChainMessageSerializer
class to pass serializers for each message type.
After creation of transport instance, you can use RM\Component\Client\ClientFactory
or RM\Component\Client\ClientConfigurator
to create an instance of client. We recommend using the configurator because he has simple settings. Factory has several setters that provide client customization.
In any case, you need to configure the following properties:
- The transport (it is required in constructor and
create()
method)
Also, you can configure these properties via factory:
- The hydrator, creates entity objects from response
- The repository registry, contains repositories created via factory
- The repository factory, creates repositories
- The authenticator factory, creates authenticators
- The authorization storage, stores the authorization data like token.
- The authorization resolver, finds credentials to pass together with request to core
- The config loader, loads the action config from resource with settings for authorization resolver
Example of creation client with HTTP transport:
Events
The package have some events to allow you to interact and to handle some cases. As example, we provided some event listeners.
Events:
- RM\Component\Client\Event\ErrorEvent
- RM\Component\Client\Event\SentEvent
- RM\Component\Client\Event\HydratedEvent
Event listeners:
- RM\Component\Client\EventListener\ThrowableSendListener - throws exception on error message and creates error event
- RM\Component\Client\EventListener\LazyLoadListener - provides lazy load for entity relations
How to add event listener (for Symfony EventDispatcher):
We recommend registering ALL event listeners provided from the package.
Also, you can overwrite event dispatcher before building:
All versions of client with dependencies
ext-mbstring Version *
remessage/message Version ^2.2.0
psr/http-message Version ^1.0
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/event-dispatcher Version ^1.0
psr/log Version ^3.0
doctrine/collections Version ^1.6
doctrine/annotations Version ^1.10
symfony/config Version ^6.0
symfony/yaml Version ^6.0