Download the PHP package olegkravec/laravel-redis-router without Composer

On this page you can find all versions of the php package olegkravec/laravel-redis-router. 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 laravel-redis-router

laravel-redis-router

Installing

composer require olegkravec/laravel-redis-router

General

laravel-redis-router is implementation similar ro Laravel MVC scheme for handling and sending Redis Pub/Sub messages

How it is working?

For example you have 2 different services, called as Service A and Service B, both of services is REST(doesnt metter) API applications, but Service B must get data from Service A. There are different way how to receive data, for example HTTP API requests, but in highload projects http requests up to version 3 is too slow for transiving data between services, so we need something better.

Redis Pub/Sub mechanism allows subscribe to channel, and publish message to all subscribers, all subscribes will receive data in real time.

We will make example where Service A will subscribe to channel users:* and receive all requests and will send back to channel response. Service B will requests some specific data(User).

Step 1 - registering Service A

For lounching laravel-redis-router we should run: php artisan listen:service users

That's mean that Service A will subscribe for {users} channel.

Step 2 - service controller for Service A

php artisan make:controller UserRedisController

Patter for creation: {SERVICE_NAME}RedisController For example: for notification service we must register NotificationRedisController... eg...

Step 3 - implementing first method for Service A

First that you must to know: each controller can be bound to Model(Eloqument), thats allow request data from Service B directly from DB via present model

We implemented test method, that has argument $data, there is no limits with arguments, you can declare as much as you need, also it can be in any basic type.

*Redis controller always must return Collection

Step 4 - requesting the data from Service B

Requesting controller's method

In your console you will see: Response is: {'0':"ok!", "key": "Hello World"}

Response is JSON object with your data.

Requesting data directly from DB

In your console you will see: Response is: Oleg

Response is JSON object with your data.

How it looks in Redis Monitor

  1. Service A subscribes to all channel with all package IDs.
  2. Service B creates package 322d3a41-c34c-46fe-aa7f-c3aff180a569 and subscibes to it's channel
  3. Service B sends to package's channel request request||where||[[\"id\",\"!=\",-65535]]
  4. Service A, that parsed request calls method where firstly in Controller, in if not present in bound Model, generates Collection of response.
  5. Generated response Service A sends to needed channel.
  6. Service B unsubscribes package's channel.

Each package should have id, and as we cannot implement numerical inctementing id we just create UUID(for ex.: 322d3a41-c34c-46fe-aa7f-c3aff180a569)

How is Protocol looks

request||where||[[\"id\",\"!=\",-65535]] this string means that received redis Pub event is actually 'Request', and within it's Controller we should call 'where' method, with arguments '[[\"id\",\"!=\",-65535]]'

Argument can be not one, for example: request||where||api_token||12345_token


All versions of laravel-redis-router with dependencies

PHP Build Version
Package Version
Requires php Version *
cheprasov/php-redis-client Version ^1.10
predis/predis Version ^1.1
laravel/framework Version ^8.0
ext-json 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 olegkravec/laravel-redis-router contains the following files

Loading the files please wait ....