Download the PHP package dinhdjj/laravel-auto-db-transaction-middleware without Composer
On this page you can find all versions of the php package dinhdjj/laravel-auto-db-transaction-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dinhdjj/laravel-auto-db-transaction-middleware
More information about dinhdjj/laravel-auto-db-transaction-middleware
Files in dinhdjj/laravel-auto-db-transaction-middleware
Package laravel-auto-db-transaction-middleware
Short Description A laravel-middleware auto activate db-transaction on each request
License MIT
Homepage https://github.com/dinhdjj/laravel-auto-db-transaction-middleware
Informations about the package laravel-auto-db-transaction-middleware
A laravel-middleware auto activate db-transaction on each request
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Requirements
* Laravel 9+
* php 8.1+
Installation
You can install the package via composer:
Usage
Firstly you should register the middleware to group or you can use middleware in specific routes.
Above is all thing you need to do.
How it works
Below I will show you how it auto activate db-transaction on each request.
- It only activate
beginTransaction
on methodPOST
,PUT
,PATCH
,DELETE
...(notGET
) methods. - In all cases it will auto
commit
and onlyrollback
when it encounter an unhandled exception. - It will also throw exceptions in some cases.
- When you miss
commit
orrollback
on your ownbeginTransaction
. - When you use redundant
commit
orrollback
db-transaction.
- When you miss
Exception handler
When an exception is thrown, in most cases behaver of this package will rollBack
the db-transaction, but if you not use default logging exception handler of laravel
the package will evaluate that you handled the exception and it will continue commit
db-transaction.
Below is the example of cases not use default logging exception handler of laravel
or
If you not use default logging exception handler of laravel
and you want to rollBack
the db-transaction, you can use this:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- dinhdjj
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-auto-db-transaction-middleware with dependencies
spatie/laravel-package-tools Version ^1.9.2
illuminate/contracts Version ^9.0