PHPackages                             elegantweb/laravel-transactional-events - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. elegantweb/laravel-transactional-events

AbandonedArchivedLibrary[Framework](/categories/framework)

elegantweb/laravel-transactional-events
=======================================

Transactional events for the Laravel framework.

v2.2.0(3y ago)3832MITPHPPHP ^7.4|^8.0

Since Dec 27Pushed 3y agoCompare

[ Source](https://github.com/elegantweb/laravel-transactional-events)[ Packagist](https://packagist.org/packages/elegantweb/laravel-transactional-events)[ RSS](/packages/elegantweb-laravel-transactional-events/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (3)Versions (9)Used By (0)

laravel-transactional-events
============================

[](#laravel-transactional-events)

[![GitHub release (latest by date)](https://camo.githubusercontent.com/c72ac481b157fd67e95affe093bf6f8a2ebf886f3f1d8d69b10198365c94494a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f656c6567616e747765622f6c61726176656c2d7472616e73616374696f6e616c2d6576656e74733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/c72ac481b157fd67e95affe093bf6f8a2ebf886f3f1d8d69b10198365c94494a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f656c6567616e747765622f6c61726176656c2d7472616e73616374696f6e616c2d6576656e74733f7374796c653d666c61742d737175617265)[![GitHub Workflow Status](https://camo.githubusercontent.com/ffbfd26b8747e5523159442244a07e1899c7ec588eab5bfdfd8569759c439e01/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656c6567616e747765622f6c61726176656c2d7472616e73616374696f6e616c2d6576656e74732f746573742e796d6c3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/ffbfd26b8747e5523159442244a07e1899c7ec588eab5bfdfd8569759c439e01/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656c6567616e747765622f6c61726176656c2d7472616e73616374696f6e616c2d6576656e74732f746573742e796d6c3f7374796c653d666c61742d737175617265)

> Transactional events for the Laravel framework.

Installation
------------

[](#installation)

```
composer require elegantweb/laravel-transactional-events
```

Why?
----

[](#why)

Take a look at the example below:

```
DB::transaction(function () {
    $post = Post::create(['title' => 'An Awesome Post!']);
    event(new PostCreated($post));
    $post->categories()->create(['name' => 'Blog']);
});
```

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
-----

[](#usage)

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

### With Transactional Interface

[](#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:

```
use Elegant\Events\TransactionalEvent;

class MyAwesomeEvent implements TransactionalEvent
{
}
```

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

### With Configuration

[](#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:

```
php artisan vendor:publish --tag="laravel-transactional-events-config"
```

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.

```
return [
    'include' => [
        'App\Events',
    ],
];
```

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.

```
return [
    'include' => [
        'App\Events',
    ],

    'exclude' => [
        'App\Events\MyAwesomeEvent',
    ],
];
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~172 days

Recently: every ~236 days

Total

8

Last Release

1125d ago

Major Versions

1.0.x-dev → v2.0.02020-09-09

PHP version history (3 changes)v1.0.0PHP ^7.2

1.0.x-devPHP ^7.4

v2.0.1PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4331089ae6e2d73d6307de5a1ca720442ca9d45a762c418e5b45e8b108094d15?d=identicon)[elegantweb](/maintainers/elegantweb)

---

Top Contributors

[![sharifzadesina](https://avatars.githubusercontent.com/u/205923701?v=4)](https://github.com/sharifzadesina "sharifzadesina (27 commits)")

---

Tags

laravelphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elegantweb-laravel-transactional-events/health.svg)

```
[![Health](https://phpackages.com/badges/elegantweb-laravel-transactional-events/health.svg)](https://phpackages.com/packages/elegantweb-laravel-transactional-events)
```

###  Alternatives

[codewithdennis/larament

Larament is a time-saving starter kit to quickly launch Laravel 13.x projects. It includes FilamentPHP 5.x pre-installed and configured, along with additional tools and features to streamline your development workflow.

3691.5k](/packages/codewithdennis-larament)[ecotone/laravel

Laravel integration for Ecotone

21307.6k3](/packages/ecotone-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
