PHPackages                             serafim/evacuator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. serafim/evacuator

ActiveLibrary

serafim/evacuator
=================

Try-catch with multiple retries

3.0.0(9y ago)162111WTFPLPHPPHP &gt;=7.0

Since Apr 6Pushed 9y ago2 watchersCompare

[ Source](https://github.com/SerafimArts/Evacuator)[ Packagist](https://packagist.org/packages/serafim/evacuator)[ Docs](https://github.com/SerafimArts/Evacuator)[ RSS](/packages/serafim-evacuator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (1)

Evacuator 3.0
=============

[](#evacuator-30)

[![Build Status](https://camo.githubusercontent.com/5cbb75b6817bcdb6f6ce208f5bbe98d3bc5f35833c25acc652cbfe9b074bb3ac/68747470733a2f2f7472617669732d63692e6f72672f5365726166696d417274732f457661637561746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SerafimArts/Evacuator)[![Code Quality](https://camo.githubusercontent.com/8517ecacb277d26e41d47af9437160b5217407498c03e9b0d4b9ef85586b55cb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5365726166696d417274732f457661637561746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/SerafimArts/Evacuator/inspections)

He trying to save your code, if it is broken :3

Installation
------------

[](#installation)

`composer require serafim/evacuator`

> Link to [Packagist](https://packagist.org/packages/serafim/evacuator)

Usage example
-------------

[](#usage-example)

```
// What we are trying to keep safe?
$result = rescue(function () {
    if (random_int(0, 9999) > 1) {
        throw new \Exception('Ooooups =(');
    }

    return 23;
});

var_dump($result); // int(23)
```

Advanced usage
--------------

[](#advanced-usage)

```
use Serafim\Evacuator\Evacuator;

$result = (new Evacuator(function() {

    // Your a very important piece of code

}))

    // Code throws an exception after 100500 call retries
    ->retry(100500)

    // or until the cancer is not on the mountain whistles...
    ->retry(Evacuator::INFINITY_RETRIES)

    // But if you want catch exception
    ->catch(function (Throwable $e) {
        return 'Something went wrong =('; // Will be returns into $result
    })

    ->finally(function ($errorOrResult) {
        // Run this code after all attempts.
        // $errorOrResult can be error (if evacuator cant keep safe your code) or result value
    })

    ->onError(function ($error) {
        // Run this code after every error
    })

    ->invoke(); // Just run your very important code
```

Catching strategy
-----------------

[](#catching-strategy)

```
$result = (new Evacuator(function() {
    throw new \LogicException('Error');
}))

    ->catch(function (\RuntimeException $e) {
        // I am alone and never be use ='(
    })
    // ->onError(function (\RuntimeException $e) {})

    ->catch(function (\LogicException $e) {
        // Yay! I will calling because Im a LogicException! :D
    })
    // ->onError(function (\LogicException $e) {})

    ->invoke();
```

Enjoy! :3

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~133 days

Total

3

Last Release

3423d ago

Major Versions

1.0.0 → 2.0.02016-05-05

2.0.0 → 3.0.02016-12-29

PHP version history (2 changes)1.0.0PHP &gt;=7.0

2.0.0PHP &gt;=5.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/150420?v=4)[Ruslan Sharipov](/maintainers/Serafim)[@serafim](https://github.com/serafim)

---

Top Contributors

[![SerafimArts](https://avatars.githubusercontent.com/u/2461257?v=4)](https://github.com/SerafimArts "SerafimArts (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/serafim-evacuator/health.svg)

```
[![Health](https://phpackages.com/badges/serafim-evacuator/health.svg)](https://phpackages.com/packages/serafim-evacuator)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
