Download the PHP package softonic/laravel-transactional-event-publisher without Composer

On this page you can find all versions of the php package softonic/laravel-transactional-event-publisher. 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-transactional-event-publisher

Laravel Transactional Event Publisher

Latest Version Build Status Coverage Status Quality Score Total Downloads Average time to resolve an issue Percentage of issues still open Laravel package to handle atomicity between Eloquent model operations and domain event message generation.

Main features

Installation

You can require the last version of the package using composer

Configuration

It is possible to configure the basic AMQP information, you can check it in vendor/softonic/transactional-event-publisher/config/transactional-event-publisher.php

If you need further customization, you can publish the configuration.

We provide Softonic\TransactionalEventPublisher\EventStoreMiddlewares\DatabaseMiddleware and Softonic\TransactionalEventPublisher\EventStoreMiddlewares\AmqpMiddleware middlewares to store and send events.

Database middleware

This middleware just stores the events in a table in database. It can be useful if you want to expose the events as a REST endpoint or check your events history.

To configure this middleware you need to publish the migrations

and execute them

Amqp middleware

This middleware publishes the events to an AMQP system. You just need to configure the AMQP connection using the configuration file or environmental variables. As you can see, in the configuration you won't be able to define a queue. This is because the library just publishes the message to an exchange and is the events collector responsibility to declare the needed queues with the needed bindings.

Publishing events in batches to improve performance

We provide a command to continuously publish events in batches. You can find its signature in Softonic\TransactionalEventPublisher\Console\Commands\EmitEvents. It will publish the events in batches of 100 by default, or you can change it with the option --batchSize. You just need to create a job that will run indefinitely with the command php artisan event-sourcing:emit.

Sending all the events stored in database

By default, the command php artisan event-sourcing:emit will send all the events stored in database using a MySQL unbuffered connection. Otherwise, a Mysql buffered Connection it is used to delete the events from database after they have been sent.

You can specify the connection to use with the option --dbConnection for the buffered connection and --dbConnectionUnbuffered for the unbuffered connection. Unbuffered connection example from config/database.php

Registering Models

To choose what models should send domain events, you need to attach the \Softonic\TransactionalEventPublisher\ModelObserver observer class.

Example:

Custom middlewares

The middlewares should implement the Softonic\TransactionalEventPublisher\Interfaces\EventStoreMiddlewareInterface interface. Its purpose is to store the domain event provided, so you can implement any storage for domain events.

Custom messages

The transactional-event.messageBuilder class must implement EventMessageBuilderInterface and transactional-event.middleware class must implement EventStoreMiddlewareInterface.

The builder should return a EventMessageInterface value object. It just needs to implement the toArray and jsonSerialize methods with all the attributes that you need.

Considerations

This package begins a database transaction in the following Eloquent Model events:

And commit the database transaction when the event store middleware stores the event message successfully. On the other hand, if the event store couldn't store the event message would be a database rollback for the two operations (Eloquent model write + event message storing). Take into account if an error occurs between the event of creating/updating/deleting and created/updated/deleted the transaction would remain started until the connection had been closed.

Testing

softonic/laravel-transactional-event-publisher has a PHPUnit test suite and a coding style compliance test suite using PHP CS Fixer.

To run the tests, run the following command from the project folder.

To open a terminal in the dev environment:

License

The Apache 2.0 license. Please see LICENSE for more information.


All versions of laravel-transactional-event-publisher with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
softonic/laravel-amqp Version ^2.4
laravel/framework Version ^9.0|^10.0
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 softonic/laravel-transactional-event-publisher contains the following files

Loading the files please wait ....