Download the PHP package elegantweb/laravel-transactional-events without Composer

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

laravel-transactional-events

GitHub release (latest by date) GitHub Workflow Status

Transactional events for the Laravel framework.

Installation

Why?

Take a look at the example below:

At the first glance, everything seems fine, but there is a big problem here!

Imagine we are sending a notification inside PostCreated event, lets see what can happen:

Situation 1: The notification fails to be sent, probably an exception will be thrown, the transaction will be rolled back and the created post will be removed from database. What actually happened is, our post got removed because of the notification failure, Ask yourself, "Is this what I want?! 🤔" Most of the time, we don't want to remove the post because of failed notifications!

Situation 2: Lets consider that the PostCreated event dispatched successfully without any error. but because of some database or application problem, we got an error when we tried to create a category for our post (How unlucky we are!!! 😩), in this case, the transaction will fail and the post will be removed from database. So far so good, but guess what?! we have already sent a notification inside the PostCreated event for the post that no longer exists! 😱

Solution: The workaround here is to make the event to dispatch after the transaction commitment. Using this package, you can make the event transactional, so the event will be postponed until the commitment of the transaction.

Usage

The package is enabled out of the box. What you need to do is to just make your events transactional.

With Transactional Interface

One possible way to make an event transactional is to implements Elegant\Events\TransactionalEvent interface. Take a look at the example below:

Now the MyAwesomeEvent class is transactional and it will be handled by the package whenever you dispatch it.

With Configuration

The other way is to use configuration file. This way, You can make a group of events transactional.

First of all publish the default config file:

We have two options, include and exclude.

Using include, you can make an event class or a group of events under certain namespace transactional.

By default we have App\Events namespace, this will cause all events under App\Events namespace to became transactional.

The exclude option is the opposite of the include option, you can exclude an event class or group of events under certain namespace from being transactional.

The example below will cause all events under App\Events namespace to become transactional except for App\Events\MyAwesomeEvent class.


All versions of laravel-transactional-events with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
laravel/framework Version ^8.0|^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 elegantweb/laravel-transactional-events contains the following files

Loading the files please wait ....