remessage / message
Message Standard for networking in Re: Message.
Installs: 90
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/remessage/message
Requires
- php: >=8.4
- ext-mbstring: *
- doctrine/collections: ^2.3
- symfony/deprecation-contracts: ^3.6
- symfony/serializer: ^7.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- phpunit/phpunit: ^12.2.0
- remessage/ruleset: ^1.3.1
This package is auto-updated.
Last update: 2025-10-14 10:43:38 UTC
README
This package defines the rules and formats for communication between clients and servers that are part of Re: Message.
Standard based on JSON format and created to implement a JSON-pure API. This package uses the symfony/serializer for encoding and decoding JSON.
The remessage/client and remessage/core based on this standard.
Requirements
PHP 8.4+ with these extensions:
- json
- mbstring
Installation
You will need Composer to install:
composer require remessage/message
Description
Message is any data sent as part of the server-client interaction. Any message MUST have a type high level property with the message type (see Types).
Transport
As a data transmission channel, HTTP or sockets can be used. See Core documentation for details.
When using the HTTP protocol, only action, response, error messages can be used.
Types
There are several types of messages for communication. The main types of messages: action, response and error. These types of messages can be sent and received via any transport.
Action
The Action message is a message, which is a request to perform some action and return its results as a Response. Action can be sent only from a client side.
Any action message MUST have a name and a parameters properties. The name property contains a name of action (e.g. auth.sendCode). The parameters property is a list of parameters for action.
Also, Action message can have these optional properties:
idproperty: a random identifier for the Action message which MUST be returned in the Response message if the identifier was senttokenproperty: access token to this action (you can pass the token in other ways)
Example:
{
"type": "action",
"name": "auth.sendCode",
"parameters": {
"phone": "+79123456789",
"requestId": "d0f2f571-d07d-4e1d-bdf6-e3470efe9ac5",
"code": "012345"
}
}
Response
The Response message is a message returned as the result of the Action if the action completed successfully. A message of this type MUST have a content property, that contains the results of action. Response can be sent only by the Core.
Also, Response message can have these optional properties:
idproperty: an identifier from the Action message if the identifier was sent
Example:
{
"type": "response",
"content": {
"method": "sms",
"requestId": "b4b12d26-8fd6-4d9f-aa2c-0e56ced951be",
"expiredAt": 1587075673
}
}
Error
The Error message is the message returned if an error occurred while performing an action. The error message MUST have a code and message properties. The code property is a number code of error. The message property is a short description about error. A complete list of errors that may be thrown is available here. Error can be sent only by the Core.
Example:
{
"type": "error",
"code": 51,
"message": "One of the passed parameters is invalid."
}