Download the PHP package vandarpay/orchestration-saga without Composer

On this page you can find all versions of the php package vandarpay/orchestration-saga. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package orchestration-saga

Orchestration Saga

This package is for implementing the Saga orchestration design pattern for designing microservices. Using this pattern, you can easily implement communication between services using Redis and RabbitMQ.

Installation

composer require vandarpay/orchestration-saga

Publish Config File

php artisan vendor:publish --provider="vandarpay\OrchestrationSaga\OrchestrationSagaServiceProvider"

Requirement

Environments

Please add this environment variable to .env file

RPC_RABBITMQ_HOST=localhost
RPC_RABBITMQ_PORT=5672
RPC_RABBITMQ_USER=guest
RPC_RABBITMQ_PASSWORD=guest
RPC_RABBITMQ_CONNECTION_TIMEOUT=30
RPC_RABBITMQ_READ_WRITE_TIMEOUT=30
RPC_RABBITMQ_KEEP_ALIVE=true
RPC_USE_EXCHANGE_LOG=true
RPC_REQUEST_TIMEOUT=30
RPC_DEBUG=false 
RPC_DEBUG_LOG_CHANNEL=rpc 
LOG_JOB=App/Jobs/RpcLogJob 

If this feature is activated, the application will use the rabbitmq exchange feature when creating queues, and all requests , responses will be duplicated in the queue with the log name.

The duration of sending a request until receiving a response from another service is set by this parameter

By activating this parameter, all communication steps in your service will be saved in the log file. Use this feature only during development. Also use the RPC_DEBUG_LOG_CHANNEL parameter to specify the log storage channel. Obviously, the channel introduced in the RPC_DEBUG_LOG_CHANNEL parameter must be defined in the logging.php file.

You can use this parameter to introduce a job to store all the states that occur for a request. The input of this job is of RpcLogJobDto type and the following statuses can be received in this job.

Generator Commands

php artisan make:callback-event
php artisan make:rollback-event
php artisan make:rpc-service

RPC Commands

php artisan rpc:listen-client
php artisan rpc:publish-client
php artisan rpc:listen-server
php artisan rpc:publish-server

Supervisor Configuration

To activate the connection between the services, you must create a process from each of the above commands. Below are the config for this task using the supervisor.

[program:swoole-publish-client-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /{Project Path}/artisan rpc:publish-client
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/{Project Path}/storage/logs/publish-client.log
stopwaitsecs=3600
logfile_maxbytes=500000000

[program:swoole-listen-client-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /{Project Path}/artisan rpc:listen-client
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/{Project Path}/storage/logs/listen-client.log
stopwaitsecs=3600
logfile_maxbytes=500000000

[program:swoole-listen-server-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /{Project Path}/artisan rpc:listen-server
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/{Project Path}/storage/logs/listen-server.log
stopwaitsecs=3600
logfile_maxbytes=500000000

[program:swoole-publish-server-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /{Project Path}/artisan rpc:publish-server
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/{Project Path}/storage/logs/publish-server.log
stopwaitsecs=3600
logfile_maxbytes=500000000

How do queues connections work?

we use the pub/sub Redis structure to persist php connection to the rabbitmq, which is given below the connection diagram.

On the server side, we use the process manager in the swoole extension to reduce the rabbitmq connection, and each process is killed after generating a response .

Rpc Service

To create an RPC client, first run the following command

php artisan make:rpc-service

And finally, to send information to the destination server, specify the name of the service and the type of connection with the following method in the service provider

An example of calling a service with the sync method is given below

Inside the class, create methods to call methods of the destination services with the required parameters. The calls can be of two types: sync(callSync) and async(callAsync), and you can also define events for success return and error return time with the following commands.

php artisan make:callback-event
php artisan make:rollback-event

Pay attention to establish the connection between your events and listeners in the event provider service

Versioning On Service

Of course, in the development of a service, there are times when there is a need to upgrade the old version, and this part is fully supported in this package. For this purpose, after considering the necessary folders for the service, do this for service transformers as well. Because the objects of the service and transformer classes are created automatically, you must set the desired version folder in the $serviceVersion variable in your rpc service when calling the services by rpc.

Below is an example of how to do this

In this case, the folder structure changes as follows


All versions of orchestration-saga with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
php-amqplib/php-amqplib Version ^3.2
vandarpay/service-repository Version ^0.1
ext-redis Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vandarpay/orchestration-saga contains the following files

Loading the files please wait ....