PHPackages                             icewind/interceptor - 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. icewind/interceptor

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

icewind/interceptor
===================

Intercept php includes

v0.3.0(10y ago)1614031MITPHPPHP &gt;=5.4

Since Sep 26Pushed 6y agoCompare

[ Source](https://github.com/icewind1991/interceptor)[ Packagist](https://packagist.org/packages/icewind/interceptor)[ RSS](/packages/icewind-interceptor/feed)WikiDiscussions master Synced 1mo ago

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

Interceptor
===========

[](#interceptor)

[![Build Status](https://camo.githubusercontent.com/9edb442059fce3694cf9dbf4f3b7caf7f592845e47272fcc1b3e8351892424c4/68747470733a2f2f7472617669732d63692e6f72672f69636577696e64313939312f696e746572636570746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/icewind1991/interceptor)[![Code Coverage](https://camo.githubusercontent.com/df6222c649d0fc048c7219f44bd82631b389744c21f5d1846a3a41ec7bb85e93/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f69636577696e64313939312f696e746572636570746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/icewind1991/interceptor/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7307961f1b599c14c598849735fdeabd05a82702bd28a7924efe56919bf06f65/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f69636577696e64313939312f696e746572636570746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/icewind1991/interceptor/?branch=master)

Intercept php includes

```
composer require icewind/interceptor

```

Usage
-----

[](#usage)

```
use Icewind\Interceptor\Interceptor;

$interceptor = new Interceptor();
$interceptor->addWhiteList(__DIR__ . '/src');
$interceptor->addHook(function($code) {
    return str_replace('foo', 'bar', $code);
});

$interceptor->setUp();

require 'src/foo.php'
```

API
---

[](#api)

- `addWhiteList(string $path)`: Add a folder to the white list
- `addBlackList(string $path)`: Add a folder to the black list
- Only white listed files will be intercepted
- A file is white listed if it has a parent folder that is white listed without there being a more direct parent folder that is black listed
- `addHook(callable $hook)`: Register a hook to the intercepter
- the registered callback will be called for every include which is intercepted
- The code being included will be passed as the first argument
- The path being included will be passed as second argument
- If the hook returns a string the loaded code will be replaced by the return value
- `setUp()` start intercepting includes
- `tearDown()` stop intercepting includes

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

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

Total

3

Last Release

3859d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ea4722a1296fa93edb98eae91349659927af69f7711cf35693be2b4c28ea618?d=identicon)[icewind1991](/maintainers/icewind1991)

---

Top Contributors

[![icewind1991](https://avatars.githubusercontent.com/u/1283854?v=4)](https://github.com/icewind1991 "icewind1991 (20 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/icewind-interceptor/health.svg)

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

###  Alternatives

[spatie/laravel-menu

Html menu generator for Laravel

9812.8M10](/packages/spatie-laravel-menu)[spatie/laravel-flash

A lightweight package to flash messages

6631.8M16](/packages/spatie-laravel-flash)[symfony/ux-vue

Integration of Vue.js in Symfony

35834.3k4](/packages/symfony-ux-vue)

PHPackages © 2026

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