Download the PHP package webrek/laravel-circuit-breaker without Composer

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

Laravel Circuit Breaker

Latest Version on Packagist Total Downloads Tests PHP Version

Stop a failing dependency from dragging your app down with it. Wrap calls to an external service in a circuit breaker: after enough failures it trips open and fails fast — so requests stop piling up on a downed endpoint — then probes for recovery and closes itself once the service is healthy again.

Why

When a downstream service (a payment gateway, a partner API, a webhook endpoint) gets slow or goes down, every request to it hangs until it times out. Those requests pile up, exhaust your workers and connection pool, and their outage becomes yours: a cascading failure. A circuit breaker watches for failures and, once they cross a threshold, cuts off subsequent calls during a cooldown so your app keeps responding while the dependency recovers.

Installation

Optionally publish the config:

State is stored in the cache. In production, point it at a centralized store (Redis) so the breaker is shared across every process and server: the array and file drivers only protect a single process.

How it works

A circuit moves between three states:

Usage

With a fallback

When a fallback is provided, an open circuit (or a failing call) returns it instead of throwing. The fallback receives the Throwable:

Without a fallback

Omit it and the breaker rethrows the underlying exception — or throws CircuitOpenException while open — for you to handle yourself:

Not every exception is a failure

A 422 from a validation error means your request was wrong, not that the service is down: it shouldn't open the breaker. List those exceptions under ignore and they pass through without affecting the circuit:

Pairs with the outbox

The relay in webrek/laravel-outbox can deliver through a breaker so it stops retrying against an already-downed endpoint, and resumes automatically once it recovers.

Observability & operations

Lifecycle events let you alert on state changes:

Event When
CircuitOpened A circuit tripped open.
CircuitHalfOpened An open circuit started a recovery trial.
CircuitClosed A circuit recovered.

Force a circuit closed by hand:

Inspect state in code with CircuitBreaker::for('payments')->state() and ->available().

Configuration

Requirements

Component Version
PHP 8.2+
Laravel 12.x / 13.x
Cache A shared store (Redis) in production

Testing

Contributing

See CONTRIBUTING.md.

Security

Please review the security policy before reporting a vulnerability.

License

Released under the MIT License.


All versions of laravel-circuit-breaker with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/cache Version ^12.0 || ^13.0
illuminate/console Version ^12.0 || ^13.0
illuminate/contracts Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.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 webrek/laravel-circuit-breaker contains the following files

Loading the files please wait ...