PHPackages                             wikimedia/request-timeout - 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. wikimedia/request-timeout

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

wikimedia/request-timeout
=========================

Request timeout library for Excimer with plain PHP fallback

v3.0.0(1y ago)2451.2k—5.7%1MITPHPPHP &gt;=8.1

Since Jan 11Pushed 2mo ago19 watchersCompare

[ Source](https://github.com/wikimedia/mediawiki-libs-RequestTimeout)[ Packagist](https://packagist.org/packages/wikimedia/request-timeout)[ Docs](https://www.mediawiki.org/wiki/RequestTimeout)[ RSS](/packages/wikimedia-request-timeout/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (8)Versions (8)Used By (1)

[Excimer](https://www.mediawiki.org/wiki/Excimer) is an extension for PHP which provides flexible userspace timers.

This library provides a global request timeout concept, ideally using Excimer, but with a fallback to set\_time\_limit() if Excimer is not available.

Typical usage:

```
use Wikimedia\RequestTimeout\RequestTimeout;

RequestTimeout::singleton()->setWallTimeLimit( 20 );

```

This sets a timer for 20 seconds of wall clock time. When it expires, a TimeoutException will be thrown.

It is possible to query the amount of time remaining:

```
if ( RequestTimeout::singleton()->getWallTimeRemaining() > 5 ) {
	do_slow_thing();
} else {
	do_fast_thing();
}

```

This works in the fallback mode.

The library provides a critical section concept. If a critical section is active, timeouts will be queued, rather than immediately thrown. The timeout exception will be thrown once no critical section is open.

```
$csp = RequestTimeout::singleton()->createCriticalSectionProvider( 5 );
$csp->enter( __METHOD__ );
try {
	do_something();
} finally {
	$csp->exit( __METHOD__ );
}

```

It is important to always exit a critical section. If the code in the critical section can throw an error, try/finally can be used to ensure that the critical section is exited. Alternatively we provide a scope variable model:

```
function foo() {
	$scope = $csp->scopedEnter( __METHOD__ );
	do_something();
}

```

The critical section exits when the scope object is destroyed. However, with this method, it is important to not terminate the request during the critical section, for example by calling `exit()`, or by keeping the scope object in global variable after the function returns. The library may throw an exception from a destructor during request shutdown, which causes a PHP fatal error.

Critical sections are not functional in the fallback mode.

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance71

Regular maintenance activity

Popularity38

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~307 days

Total

7

Last Release

384d ago

Major Versions

1.2.0 → 2.0.02024-11-12

v2.0.2 → v3.0.02025-06-15

PHP version history (3 changes)1.0.0PHP &gt;=7.2

2.0.0PHP &gt;=7.4

v3.0.0PHP &gt;=8.1

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/716c86d71cbf921e7912a505f89d799de398fc0a3af0bd4c8862834b2d642bd7?d=identicon)[wikimedia](/maintainers/wikimedia)

![](https://avatars.githubusercontent.com/u/81392?v=4)[Kunal Mehta](/maintainers/legoktm)[@legoktm](https://github.com/legoktm)

---

Top Contributors

[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (10 commits)")[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (9 commits)")[![tstarling](https://avatars.githubusercontent.com/u/389141?v=4)](https://github.com/tstarling "tstarling (6 commits)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (4 commits)")[![tgr](https://avatars.githubusercontent.com/u/145412?v=4)](https://github.com/tgr "tgr (2 commits)")[![legoktm](https://avatars.githubusercontent.com/u/81392?v=4)](https://github.com/legoktm "legoktm (1 commits)")[![supertassu](https://avatars.githubusercontent.com/u/9721638?v=4)](https://github.com/supertassu "supertassu (1 commits)")[![Krinkle](https://avatars.githubusercontent.com/u/156867?v=4)](https://github.com/Krinkle "Krinkle (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikimedia-request-timeout/health.svg)

```
[![Health](https://phpackages.com/badges/wikimedia-request-timeout/health.svg)](https://phpackages.com/packages/wikimedia-request-timeout)
```

PHPackages © 2026

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