Download the PHP package waska14/laravel-with-db-transactions without Composer

On this page you can find all versions of the php package waska14/laravel-with-db-transactions. 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-with-db-transactions

waska14/laravel-with-db-transactions

Are you tired of writing database transactions for every controller method?

This package solves the problem with middleware.

Middleware begins database transaction and depending response (and config also) commits/rollbacks it.

Docs

Installation

Add the package in your composer.json by executing the command.

For Laravel versions before 5.5 or if not using auto-discovery, register the service provider in config/app.php

Configuration

If you want to change default configuration, you must publish default configuration file to your project by running this command in console:

This command will copy file [/vendor/waska14/laravel-with-db-transactions/config/waska.with_db_transactions.php] to [/config/waska.with_db_transactions.php]

Default waska.with_db_transactions.php looks like:

You can manage route middleware globally (automatically) from config:

Key Value(s) Comment
middleware_groups Keys of protected $middlewareGroups from app/Http/Kernel.php. Every route having the group middleware will be processed with database transaction.
ignore_request_methods HTTP request methods names (GET/HEAD) Those methods won'be processed with database transaction.
ignore_route_names route names Those methods also won't be processed with database transaction.
commit_http_statuses HTTP status codes If transaction has begun and the response has any of those statuses, the transaction will be committed.
maximum_attempts integer Maybe if deadlocks occurs or something else

If you want manually management, you can use middleware_alias (or change it, also) as route middleware.

Manual usage

If you define middleware_groups as an empty array in config, none of the routes will be processed with database transactions by default, until you set manually the middleware for the specific routes/route groups.

Note that you can fill middleware_groups and also use middleware manually anywhere you want the method to be processed with database transaction.

Default middleware alias is with_db_transactions which can be changed in config, also.

Note that all configuration (ignore_route_names, ignore_request_methods, maximum_attempts, commit_http_statuses etc.) will also work when using this package manually.

Actions and Events

After version 2.0.0 you can define closures that will be executed before/after commit/rollback(s).

There are 6 static functions that you can call with Waska\LaravelWithDBTransactions\Helpers\WithDBTransactions class:

Usage:

Note that each function can be called as many times as you want. All closures will be executed with the same sequence. E.x:

After rollback storage/logs/laravel.log looks like:

After version 2.0.0 package dispatches events also.

You can listen them and do whatever you want in listener.

List of events:


All versions of laravel-with-db-transactions with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.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 waska14/laravel-with-db-transactions contains the following files

Loading the files please wait ....