Download the PHP package prismamedia/php-endeavor without Composer

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

Endeavor (PHP)

Endeavor is a PHP utility to retry anything, using various strategies.

Requirements

Installation

Using Composer:

Usage

Simply wrap the code you want to retry in a Closure in the run() method:

By default, Endeavor will try to run the given code 5 times. If the first attempt is successful, Endeavor will stop. But if the code fails at each attempt, Endeavor will throw an exception on the last attempt.

The maximum number of attempts can be specified using the second argument of the constructor:

In this example, it will run the code 3 times and throw on the third attempt if it continues to fail.

Keep in mind that the maximum number of attempts includes the first.

A maximum delay can be specified to create a ceiling using the third argument of the constructor:

In this example, the code will be executed 5 times with an exponential strategy which doubles the delay at each attempt to a maximum of 5 seconds.

Strategies

Endeavor can be instantiated with various strategies, depending on the expected retry interval.

Each strategy takes a required delay in milliseconds and compute the next attempt delay based on the nature of the strategy.

ConstantStrategy

This is the simplest strategy. It takes a fixed delay and sets the interval between attempt to that number.

LinearStrategy

This strategy takes an initial delay and adds it up at each attempt.

ExponentialStrategy

This strategy takes an initial delay and doubles it at each attempt.

MultiplicativeStrategy

This strategy takes an initial delay and a multiplier then multiplies the delay at each attempt.

Error handling

By default, Endeavor will simply retry the code when an Exception is thrown, then throw the last encountered Exception when reaching the maximum number of attempts.

An error handler can be specified using a Closure which will be executed after each unsuccessful attempt.

It can be used for logging purpose:

Or even throwing another Exception and stopping Endeavor if the error is unrecoverable:

It can also be used to change the current strategy:

Testing

Testing a class which uses Endeavor can dramatically slow down the execution of tests.

Symfony context

On a Symfony project, this can be resolved using the symfony/phpunit-bridge package and the included ClockMock.

_See the documentation on how to setup the bridge and use the @group time-sensitive annotation._

Finally, on the tests/bootstrap.php (documentation), register the Endeavor class:

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

BSD 3-Clause


All versions of php-endeavor with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 prismamedia/php-endeavor contains the following files

Loading the files please wait ....