Download the PHP package asimlqt/transact without Composer

On this page you can find all versions of the php package asimlqt/transact. 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 transact

Transact

Transact is a transaction library for PHP similar to the way database transactions work but for PHP code.

The purpose is to be able to execute multiple actions which might depend on the previous action completing successfully before eexecuting the next one and in case of failure you want to revert back to the original state.

Installation

Use the following composer command to install

Example

The following example creates 3 simple actions that echo some text during the execute and revert methods. This example will be referenced throughout the rest of the README and only changes will be listed.

The output of the program is

Order of execution

The actions are executed in the order they are added. When there is an error i.e. when an exception is thrown the revert methods will be called in reverse order. The revert method of the last successful action will be called first then the one before that etc. all the way to the first action.

For example if the third action threw an exception then the revert method of Action2 will be called then the revert method of Action1:

The output of will be:

You've probably noticed that the Action3 execute method through an exception so why wasn't the revert method of Action3 called? That's becasue each action should perform only one task, so if an action threw an exception becasue it couldn't complete the task then there is nothing to revert!

Passing data to actions

Usually the actions will need some data to perform their tasks so to do this use the Intent object which is a simple wrapper around an array. It only has 2 methods get and set. This will automatically be injected into the actions before the execute method is called.

Then in the Action you can retrieve the user using:

Note that the same intent object will be forwarded to all actions so it is possible to overwrite data. It can also be useful if you need to pass data from one action to another.

Retry Policies

If an action fails to complete it's task due to some external factor you might want to try the action again e.g. making an API request. Retry policies can be specified for both, execute and revert. They are action specific so you can only specify a retry policy for only one action or different policies for different actions. The following policies are currently available:

RetryNone

This is the default policy if you don't explicitly specify one. this does not perform any retries.

RetryOnce

This will immediately try the action again before marking it as failed.

RetryNumTimes

This will try the action repeatedly for the specified number of times.

RetryAfter

This will retry the request once more after a delay of specified microseconds.

You will need to set these on the Action objects before adding them to the transaction manager:


All versions of transact with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.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 asimlqt/transact contains the following files

Loading the files please wait ....