PHPackages                             rajentrivedi/transaction-x - 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. rajentrivedi/transaction-x

ActiveLibrary

rajentrivedi/transaction-x
==========================

implements database transaction with ease

1.0.0(2y ago)15171[4 PRs](https://github.com/rajentrivedi/transaction-x/pulls)MITPHPPHP ^8.1CI passing

Since Nov 24Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/rajentrivedi/transaction-x)[ Packagist](https://packagist.org/packages/rajentrivedi/transaction-x)[ Docs](https://github.com/rajen-trivedi/transaction-x)[ RSS](/packages/rajentrivedi-transaction-x/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (6)Used By (0)

TransactionX - Laravel Transaction Package
==========================================

[](#transactionx---laravel-transaction-package)

**TransactionX** is a powerful Laravel package designed to simplify database transactions within your application. This package provides a seamless way to handle database transactions for specific routes, ensuring data integrity and consistency.

Features
--------

[](#features)

- **Automatic Transactions:** TransactionX automatically manages database transactions for routes where it is applied. It starts a transaction before the route is executed and commits or rolls back the transaction based on the route's outcome.
- **Conditional Execution:** The package executes transactions only for non-GET requests, minimizing the impact on read-only operations and optimizing the database interactions for data-altering requests.
- **Error Handling:** TransactionX intelligently handles exceptions and errors during the route execution. If an exception occurs or if there are errors reported by Laravel's error handling system, the middleware rolls back the transaction to maintain a consistent state.

Getting Started
---------------

[](#getting-started)

**Installation:**

Install the TransactionX package using Composer.

```
composer require rajentrivedi/transaction-x
```

**Setup:**

Apply the TransactionMiddleware to the route group where you want to enable automatic transactions.

```
Route::group(['middleware' => 'transaction-x'], function () {
    	// Your routes here
});
```

Or, you can apply the TransactionMiddleware to specific route.

```
Route::post('/example', function () {
    	DB::table('your_table')->insert(['column' => 'value']);
		DB::table('some_other_table')->insert(['column' => 'value']);
    	return response()->json(['success' => true]);
})->middleware('transaction-x');
```

Before Applying TransactionX
----------------------------

[](#before-applying-transactionx)

```
use Illuminate\Support\Facades\DB;
use App\Models\User;
use App\Models\UserProfile;

class UserController extends Controller
{
    public function updateProfile(Request $request, $userId)
    {
        try {
            DB::beginTransaction();

            // Update user profile logic
            $user = User::find($userId);
            $user->update($request->all());

            // Additional operations with other tables
            $profile = UserProfile::where('user_id', $userId)->first();
            $profile->update($request->get('profile_data'));

            // Another operation...

            DB::commit();

            return response()->json(['success' => true]);
        } catch (\Exception $e) {
            DB::rollBack();

            return response()->json(['error' => $e->getMessage()], 500);
        }
    }
}
```

In this example, there are operations involving two different tables (User and UserProfile). Manually handling transactions in this scenario can lead to increased complexity and a higher chance of errors.

After Applying TransactionX
---------------------------

[](#after-applying-transactionx)

```
use App\Models\User;
use App\Models\UserProfile;
class UserController extends Controller
{

    public function updateProfile(Request $request, $userId)
    {
        // Update user profile logic
        $user = User::find($userId);
        $user->update($request->all());

        // Additional operations with other tables
        $profile = UserProfile::where('user_id', $userId)->first();
        $profile->update($request->get('profile_data'));

        // Another operation...

        return response()->json(['success' => true]);
    }
}
```

With TransactionX, the middleware takes care of the transaction handling, even when there are multiple database interactions within the same route. This leads to cleaner and more readable code, as the developer can focus on the logic of the route without the need to manage transactions explicitly. The middleware ensures that the transactions are handled consistently across different tables, promoting code cleanliness and maintainability.

Enjoy Consistent Transactions
-----------------------------

[](#enjoy-consistent-transactions)

With TransactionX, focus on building your application logic, while the package ensures that your database transactions are handled consistently.

Contribution
------------

[](#contribution)

If you encounter issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the GitHub repository.

License
-------

[](#license)

TransactionX is open-source software licensed under the MIT License.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance59

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

900d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9519df9e8edfdd9469fe1a8bbab465bec2f9fe71bf9f6088f9ee906fc6c07715?d=identicon)[rajentrivedi](/maintainers/rajentrivedi)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")[![rajenindianic](https://avatars.githubusercontent.com/u/94968368?v=4)](https://github.com/rajenindianic "rajenindianic (9 commits)")[![rajentrivedi](https://avatars.githubusercontent.com/u/69707769?v=4)](https://github.com/rajentrivedi "rajentrivedi (6 commits)")[![abrardev99](https://avatars.githubusercontent.com/u/54532330?v=4)](https://github.com/abrardev99 "abrardev99 (1 commits)")

---

Tags

laravelRajen Triveditransaction-x

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/rajentrivedi-transaction-x/health.svg)

```
[![Health](https://phpackages.com/badges/rajentrivedi-transaction-x/health.svg)](https://phpackages.com/packages/rajentrivedi-transaction-x)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)

PHPackages © 2026

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