Download the PHP package stfn/php-circuit-breaker without Composer

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

Circuit breaker in PHP

Latest Version on Packagist

This package provides an implementation of the circuit breaker pattern in PHP. You can find more info about it here.

Installation

You can install the package via composer:

Usage

Wrap your potentially error-prone function with the circuit breaker, and it will monitor and handle failures.

States

Circuit breaker can have 4 different states.

Closed

In the Closed state, the circuit breaker is fully operational, allowing calls to the 3rd party service. Any exceptions that occur during this state are counted.

Half Open

The Half Open state is a transitional phase where the circuit breaker allows a limited number of calls to the 3rd party service. If these calls are successful, the circuit is closed again. However, if the service continues to exhibit issues, the circuit is moved back to the Open state.

Open

The Open state indicates that the circuit breaker has detected a critical failure, and the call method will fail immediately, throwing a CircuitOpenException exception.

Force Open

Force Open is not part of the regular flow. It can be utilized when intentional suspension of calls to a service is required. In this state, a CircuitOpenException will be thrown.

To force the circuit breaker into the Force Open state, use the following:

This feature provides a manual override to stop calls to a service temporarily, offering additional control when needed.

Storage

By default, the circuit breaker uses InMemoryStorage as a storage driver, which is not suitable for most of PHP applications.

More useful would be to use RedisStorage.

You could also write your implementation of storage. You should just implement CircuitBreakerStorage interface.

Configuration

Each circuit breaker has default configuration settings, but you can customize them to fit your needs:

Excluding some failures

Change the circuit breaker behavior by configuring it to exclude certain types of failures:

Listeners

You can add listeners for circuit breaker actions by extending the CircuitBreakerListener class:

Attach the listener to the circuit breaker:

Testing

License

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


All versions of php-circuit-breaker with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-redis Version *
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 stfn/php-circuit-breaker contains the following files

Loading the files please wait ....