Download the PHP package niclas-van-eyk/laravel-transactional-controllers without Composer

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

#[Transactional] Laravel Controllers

Effortlessly wrap your controller actions with database transactions.

Latest Version on Packagist Total Downloads

Installation

You can install the package via composer:

Background

If you want to make a series of edits to your database, where either all should happen at once, or none at all, you typically use database transactions. The example we use here is a user ($author) transferring a certain $amount of to another user ($receiver). We also want to save that the fact that this transfer took place in a separate model (TransferLog).

Usage

Before you might have written something like this:

You have to wrap your whole code inside one big closure, explicitly use all parameters you inject, and if you want to return something from inside the transaction closure, you end up with this double return, making the code harder to read and your IDE angry.

laravel-transactional-controllers solves this, by eliminating the need to wrap the code inside a closure and instead adding the Transactional attribute to the controller method:

No more use, double returns or your IDE complaining about it not being able to guarantee a correct return type!

You can also explicitly specify the database connection to use for running the transaction (config('database.default') is used by default):

Limitations

This only works when using controllers:

Implementation Details

This package uses Laravels ControllerDispatcher component, which determines how the controller action should be executed. This means we can defer opening a transaction until the last possible moment, preventing unnecessary transactions from being opened! If e.g. the validation inside a FormRequest fails, or a model is not found when using route model binding, no transaction is started.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

If you have any ideas for changes, feel free to open issues, PRs or fork the project.

Local Development

This assumes you already have installed sqlite, PHP, and all composer dependencies locally.

Run tests

Run formatter

Run analysis

Run all of the above at once

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-transactional-controllers with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^9.0 || ^10.0
illuminate/database Version ^9.0 || ^10.0
illuminate/routing Version ^9.5 || ^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 niclas-van-eyk/laravel-transactional-controllers contains the following files

Loading the files please wait ....