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

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

CI Latest Stable Version PHP Version Laravel Version Buy me a coffee

A Laravel integration for PHP Circuit Breaker v3 with multiple storage drivers, HTTP middleware, Artisan commands, and full event system integration.

What Is a Circuit Breaker?

When your application calls an external service (payment gateway, email API, etc.), that service can become slow or unresponsive. Without protection, your application keeps sending requests — piling up timeouts, wasting resources, and degrading user experience.

A circuit breaker monitors failures and automatically stops calling a failing service, giving it time to recover. It works like an electrical circuit breaker: when too many failures occur, the circuit "opens" and all requests fail fast without actually hitting the remote service.

State Behaviour
Closed Normal operation. Requests pass through. Failures are counted.
Open Requests are blocked immediately (fail fast). No calls reach the service.
Half-Open A limited number of probe requests are allowed through to test recovery.

Requirements

Installation

Publish the configuration file:

Configuration

After publishing, the config lives at config/circuit_breaker.php.

Storage Driver

Choose where circuit state is persisted:

Driver Best for Requirement
redis Distributed / multi-server apps ext-redis (phpredis)
apcu Single-server, high performance ext-apcu
memcached Distributed caching ext-memcached
array Testing and local development none

Note: The Redis driver requires the phpredis PHP extension. Predis is not supported by the underlying storage adapter.

Default Thresholds

Per-Service Overrides

Different services can have different thresholds. Any key you omit falls back to the value in defaults:

Usage

Facade

Dependency Injection

HTTP Middleware

The circuit-breaker middleware wraps an entire route. It blocks requests when the circuit is open and automatically records successes and failures based on the HTTP status code.

Register the middleware on your routes:

When the circuit is open the middleware returns a JSON response:

with HTTP status 503 Service Unavailable.

Artisan Commands

Events

All circuit breaker events are dispatched through Laravel's event system, so you can listen to them like any other Laravel event:

Event Fired when
FailureRecordedEvent A failure is recorded
SuccessRecordedEvent A success is recorded
CircuitOpenedEvent The circuit transitions to OPEN
CircuitClosedEvent The circuit transitions to CLOSED
CircuitHalfOpenEvent The circuit transitions to HALF_OPEN

Every event exposes getServiceName(): string and getOccurredAt(): DateTimeImmutable.

Manual Override

Force a circuit state for maintenance windows or during an incident:

Upgrade from v1

See UPGRADE-2.0.md for step-by-step migration instructions.

Development

Support

If you find this package useful, consider supporting it:

Buy me a coffee

License

MIT. See LICENSE for details.


All versions of laravel-circuit-breaker with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
gabrielanhaia/php-circuit-breaker Version ^3.0
illuminate/contracts Version ^11.0||^12.0
illuminate/support Version ^11.0||^12.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 gabrielanhaia/laravel-circuit-breaker contains the following files

Loading the files please wait ...