Download the PHP package jlorente/laravel-transaction-commit-queue without Composer

On this page you can find all versions of the php package jlorente/laravel-transaction-commit-queue. 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-transaction-commit-queue

Laravel Transaction Commit Queue

A Laravel queue connector to process jobs on successful database transactions commits.

This connector is very similar to the "sync" connector with the difference that jobs are executed after the database transaction has been committed instead of instantly.

It is useful for example when sending notifications that cause that other processes or third party applications read data from your database. When using database transactions and sending notifications, with another queue connectors there is no guarantee that this processes or third parties will find the data as you have set it when you sent the notification as the transaction might not has been committed yet. With this connector, the notifications will be sent on transaction commit event when the database transaction level reaches "0".

Installation

The preferred way to install this extension is through composer.

With Composer installed, you can then install the extension using the following commands:

or add

to the section of your composer.json file.

Configuration

Register the ServiceProvider in your config/app.php service provider list.

config/app.php

Then add the driver to the application config queue file.

config\queue.php

And publish the configuration file.

Usage

See the Laravel documentation to learn how to use jobs and queues.

The basic usage of this queue is like in the following example.

Here, the job specified as callback will be delayed until the transaction is committed.

Dispatching jobs on nested transactions

You can dispatch jobs to this queue inside nested transactions and the jobs will be processed after all the transactions have been resolved and the commit has been perfomed into the database.

In this example, the job is dispatched on the transaction created on nestedRun method, but this method is called by the run method from inside another transaction. The execution of the $model->notify() callback will be delayed until all the transactions have been committed.

Multiple database connections

The queue driver will use the connection names defined in the database config file in order to create different queues for each connection.

If you don't specify the queue where to dispatch the job, the default queue will be used and the queue will be processed when the default connection reaches the transaction level of 0.

If you want to init a transaction in other database connection than the default one, remember to specify the queue with the connection name on the dispatched jobs to the transaction-commit-queue like in the following example.

Testing

If you use a transaction rollback strategy for testing against the datatabase, you can set the environment variable TRANSACTION_COMMIT_DISPATCH_INSTANTLY in order to dispatch the jobs instantly instead of on transaction commit.

Further Considerations

If there isn't any open transaction on the database connection, the job with be fired instantly.

If a transaction is rolled back, all the pending jobs of the rolled back connection will be discarded.

Remember that notifications can also be enqueued.

License

Copyright © 2020 José Lorente Martín [email protected].

Licensed under the BSD 3-Clause License. See LICENSE.txt for details.


All versions of laravel-transaction-commit-queue with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
illuminate/support Version >=5.5
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 jlorente/laravel-transaction-commit-queue contains the following files

Loading the files please wait ....