PHPackages                             dangoodman/deferred - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dangoodman/deferred

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dangoodman/deferred
===================

Deferred callback execution based on RAII

1.0.1(9y ago)23.1k1MITPHPPHP &gt;=5.3.0

Since May 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/dangoodman/deferred)[ Packagist](https://packagist.org/packages/dangoodman/deferred)[ RSS](/packages/dangoodman-deferred/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

[![Build Status](https://camo.githubusercontent.com/c4b7540583c1f55123f32ab15467c7ce8036eb9af2a0d40ae28272159fa22471/68747470733a2f2f7472617669732d63692e6f72672f64616e676f6f646d616e2f64656665727265642e706e67)](https://travis-ci.org/dangoodman/deferred)

Deferred
========

[](#deferred)

Deferred callback execution based on RAII.

Usage example:

```
    function download($url, $toFile)
    {
        // Temporary increase memory limit for this function
        // $restoreMemoryLimit automatically called upon function exit
        $prevMemoryLimit = ini_get('memory_limit');
        ini_set('memory_limit', '256M');
        $restoreMemoryLimit = new Deferred(function() use($prevMemoryLimit) {
            ini_set('memory_limit', $prevMemoryLimit);
        });

        $contents = file_get_contents($url);
        if (!$contents) {
            throw new \RuntimeException("Couldn't fetch url contents");
        }

        if (file_put_contents($toFile, $contents) === false) {
            throw new \RuntimeException("Couldn't save url contents to file '{$toFile}'");
        }

        return $contents;
    }
```

Compare it with following example without deferreds:

```
    function downloadWithouDeferred($url, $toFile)
    {
        $prevMemoryLimit = ini_get('memory_limit');
        ini_set('memory_limit', '256M');

        $contents = file_get_contents($url);
        if (!$contents) {
            ini_set('memory_limit', $prevMemoryLimit);
            throw new \RuntimeException("Couldn't fetch url contents");
        }

        if (file_put_contents($toFile, $contents) === false) {
            ini_set('memory_limit', $prevMemoryLimit);
            throw new \RuntimeException("Couldn't save url contents to file '{$toFile}'");
        }

        ini_set('memory_limit', $prevMemoryLimit);

        return $contents;
    }
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~337 days

Total

2

Last Release

3309d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d07cc7bd6ec44efe5186eaf32b576a0e4199e3804caf61cf7f9e309bb5b3d992?d=identicon)[dangoodman](/maintainers/dangoodman)

---

Top Contributors

[![dangoodman](https://avatars.githubusercontent.com/u/345718?v=4)](https://github.com/dangoodman "dangoodman (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dangoodman-deferred/health.svg)

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

PHPackages © 2026

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