matrozov/yii2-transaction-checker

Component for checking the closing of transactions at the time of completion of work on a request

dev-master 2020-11-26 18:26 UTC

This package is auto-updated.

Last update: 2024-03-27 15:08:33 UTC


README

Component for checking the closing of transactions at the time of completion of work on a request.

Allows you to check for different database connections and for a variable number of events. By default, the component checks upon the Application::EVENT_AFTER_REQUEST event, as well as upon completion of the script, if it was stopped more rigidly.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist matrozov/yii2-transaction-checker "*"

or add

"matrozov/yii2-transaction-checker": "*"

to the require section of your composer.json file.

Usage

Specify the component and point it to the bootstrap section of the framework.

'bootstrap' => ['transactionChecker'],
'components' => [
    'transactionChecker' => [
        'class' => 'matrozov\yii2-transaction-checker\TransactionChecker',
    ],
],

You can directly specify the database components in which to check for transaction completion in the component configuration. By default, the component is "db".

'connections' => ['db', 'db2'],

You can also use events in other components to control the completion of transactions in other cases. For example, if the processing of an event from the queue is completed.

'extendedEvents' => [
   'myComponent'  => 'final-work-event',
   'myComponent2' => ['final-work-event-1', 'final-work-event-2'],
],