Download the PHP package amranidev/micro-bus without Composer

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

Build your laravel microservices with micro-bus

Build Status Total Downloads StyleCI Latest Stable Version License

What is micro-bus?

MicroBus is a laravel/lumen package for building microservices with event-driven architecture (Pub-Sub) using Amazon web services (SNS/SQS).

What is event-driven microservices?

Installation.

Laravel.

  1. Install the package, composer require amranidev/micro-bus.

  2. Publish the subscriber config file, php artisan vendor:publish --tag=subscriber.

  3. Publish the publisher config file, php artisan vendor:publish --tag=publisher.

  4. Add the subscriber and the publisher environment variables.

    • In the .env file add.
    1. Add the Queue connection configuration in config/queue.php.

Congratulations you have successfully installed micro-bus :rocket:

Lumen.

  1. Install the package, composer require amranidev/micro-bus.

  2. Add the subscriber and the publisher environment variables.

    • In the .env file add.
  3. Create config folder in the root directory.

  4. Create subscriber.php in the config folder.

  5. Create publisher.php in the config folder.

  6. Create queue.php in the config folder.

Copy the same queue.php from laravel/laravel and add the subscriber configuration into connections.

  1. Configure subscriber, publisher, queue and register the ServiceProvider in bootstrap/app.php.

Congratulations you have successfully installed micro-bus in lumen :rocket:

Usage.

Note that you need to define your Topics in SNS, create the queues in SQS and tie SNS topics to the queues, AWS configuration is not included in this documentation.

After installing the package in both laravel nodes, now, let's make them talk to each other. Basically, they can be both subscribers or publishers at the same time, or, you can make one as subscriber and the other as publisher, it is entirely up to you.

Let's say we have a laravel app called A and a lumen microservice called B.

When a user is created in the A, B needs to add the user's email to the mailing list,

In this case A is the publisher and B is the subscriber.

Note that the SNS configuration needs to be added to A and the SQS needs to be added in B, see installation steps above.

Setup Laravel app (Microservice A).

First of all, let's add the topic that we've created in AWS to A, we need to specify an event name user_created and the AWS TopicArn in config/publisher.php

After we configured the SNS in A, we need to add the functionality, when a user is created, we need to publish a message to SNS, to do so:

Alternatively you can publish messages with:

php artisan bus:publish <data> <eventOrTopicname>

Set up Lumen (Microservice B).

Now, let's create the subscriber class which will be listening for A in B.

This command will scaffold a job class for you in app/Subscribers/.

As you can see, the job created has $payload property, it is simply the piece of data that A will be publishing, in our case will be the $user.

The Handle method is the one responsible for executing the job coming form SQS,

The last thing we need to do in B is to tie this class to the TopicArn in config/subscriber.php.

And run the queue:work command, php artisan queue:work <connection-name>,

Contributing.

Thank you for considering contributing to this project! The contribution guide can be found in Contribution guide.

Alternative (Google Cloud Platform).

gdg-tangier/cloud-pubsub

Testing.

docker pull localstack/localstack

Create a docker-compose.yml file.


All versions of micro-bus with dependencies

PHP Build Version
Package Version
Requires aws/aws-sdk-php Version ^3.95
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 amranidev/micro-bus contains the following files

Loading the files please wait ....