Download the PHP package otas/microservice without Composer

On this page you can find all versions of the php package otas/microservice. 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 microservice

Otas/MicroService

otas/microservice is a Laravel package for dealing with specific case of micro-services connection so, it doesn't suit all needs or handle all connection cases.

Table of Content

Installation

Connecting two services

Usage

Keys renewal

When a service origin changes

How a request is protected

Upgrading from 1.x

License

Installation

You can install the package using composer

Important:

Don't forget to modify the added env key MS_GLOBAL_PROJECT_SECRET to exactly match all other microservices projects MS_GLOBAL_PROJECT_SECRET then run:

Using micro-service middleware on micro-services routes group is a must as it's responsible about decoding requests in order to make you deal with it as you usually do. Otherwise it will lead to unexpected results.

Note:

Don't use micro-service-establish-connection on any request yourself. It's already running on the predefined micro-services store route.

Connecting two services

Run the next command on one of the two services only. It asks for the other service name and origin, then both services save the keys of each other.

Usage

There is some predefined methods that will help you communicate with other services shown below:

The above methods are must to be used if you need to encrypt requests between micro-services.

Inside a request that passed the micro-service middleware, MsHttp::current() returns the service that sent it.

Keys renewal

Every two connected services have their own keys, saved encrypted in the microservice_tokens table. Each service renews the keys it receives with by itself.

Add the renewal command to your app scheduler. It should run every 30 minutes or less:

When a service origin changes

If a connected service moves to a new origin, run the next command on every service that talks to it. The keys stay the same.

On the service that moved, update APP_URL then run php artisan config:cache, as queued jobs send their origin from it.

How a request is protected

  1. X-MS-Access-Key header: checked first. A request without a valid access key is rejected before any decryption.
  2. The data is encrypted with aes-256-gcm. The request body only has these fields:
    • ms_data: the encrypted data.
    • ms_iv: a random value that makes every encryption different.
    • ms_tag: proves that nothing in the request was changed.
  3. The encrypted data also carries the time it was sent and a random one time value (nonce). A request older than request_expires_after_seconds (default 120) or sent twice is rejected.

Note:

The servers clocks must be in sync (EX: NTP) within request_expires_after_seconds, otherwise all requests are rejected.

Upgrading from 1.x

This version uses a new request format, so a service on 1.x can't talk to a service on this version. Upgrade all connected services together.

  1. Update the package to the new major version on every service.
    • A service that still uses solutionplus/microservice must move to otas/microservice and replace the Solutionplus\MicroService namespace with Otas\MicroService.
    • Laravel 11 or newer is required.
  2. Publish and run the new migrations:

    They create the microservice_tokens table and drop the unused destination_key column.

  3. Update config/microservice.php by hand (the package doesn't merge its config):
    • Remove local_secret, and remove MS_LOCAL_SECRET from .env.
    • Optionally add 'request_expires_after_seconds' => 120,.
  4. Schedule ms:renew-keys as shown in Keys renewal.
  5. Run php artisan ms:establish once for every two connected services, from one side only.

License

Otas/MicroService package is limited and proprietary software belongs to Otas.net company.


All versions of microservice with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version >=9
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 otas/microservice contains the following files

Loading the files please wait ...