PHPackages                             sanprojects/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. [HTTP &amp; Networking](/categories/http)
4. /
5. sanprojects/interceptor

ActiveLibrary[HTTP &amp; Networking](/categories/http)

sanprojects/interceptor
=======================

Intercept php functions

1.0.21(1y ago)1040.7k—10%[2 PRs](https://github.com/sanprojects/interceptor/pulls)MITPHPPHP &gt;=8.1

Since Mar 15Pushed 1y ago3 watchersCompare

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

READMEChangelogDependencies (4)Versions (27)Used By (0)

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

[](#interceptor)

Intercepts external request in php scripts, and log it to `STDERR`. So you can better understand what doing your program.

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

[](#installation)

```
composer require sanprojects/interceptor
```

Basic Usage:
------------

[](#basic-usage)

```
// Intercept all kind of requests
\Sanprojects\Interceptor\Interceptor::interceptAll();
```

Now in the console you'll see something like this:

```
Interceptor.DEBUG: curl -vX POST 'https://www.example.com/' \
 --data 'postvar1=value1&postvar2=value2&postvar3=value3'
Interceptor.DEBUG: CURL>  ...
Interceptor.DEBUG: fopen /Users/san/PhpstormProjects/interceptor/tests/test.txt w+b [resource(stream)]
Interceptor.DEBUG: fwrite /Users/san/PhpstormProjects/interceptor/tests/test.txt test 4
Interceptor.DEBUG: fread /Users/san/PhpstormProjects/interceptor/tests/test.txt 100 test
Interceptor.DEBUG: file_put_contents /Users/san/PhpstormProjects/interceptor/tests/test.txt test 4
Interceptor.DEBUG: Redis::__construct NULL
Interceptor.DEBUG: Redis tcp://127.0.0.1:6379 set test {"jsonKey":123} Predis\Response\Status
Interceptor.DEBUG: Redis tcp://127.0.0.1:6379 get test {"jsonKey":123}
Interceptor.DEBUG: mysqli_connect ensembldb.ensembl.org anonymous  mysqli
Interceptor.DEBUG: mysqli_query ensembldb.ensembl.org SELECT 123 mysqli_result
Interceptor.DEBUG: PDO::__construct mysql:dbname=;host=ensembldb.ensembl.org anonymous  NULL
Interceptor.DEBUG: PDO::query SELECT 123 Sanprojects\Interceptor\Hooks\PDOStatement
Interceptor.DEBUG: PDOStatement::execute SELECT 123; true

```

How it works
------------

[](#how-it-works)

It use `stream_wrapper_register` to intercept included php files and `stream_filter_register` for rewrite source code.

Support
-------

[](#support)

curl, fwrite, fread, file\_get\_contents, file\_put\_contents, mysqli, Redis, PDO, AMQP.

Caveats
-------

[](#caveats)

- It turns off opcache.
- Because of source code injection, it can crush your app. Not all cases tested.

How to inject
-------------

[](#how-to-inject)

Option 1: Run interceptor.phar

```
curl -O https://sanprojects.github.io/interceptor/interceptor.phar
php -d opcache.enable=0 interceptor.phar
```

Option 2: Use `auto_prepend_file`

```
curl -O https://sanprojects.github.io/interceptor/interceptor.phar
php -d opcache.enable=0 -d auto_prepend_file=interceptor.php
```

Option 1: Include in your script

```
\Sanprojects\Interceptor\Interceptor::interceptAll();
```

Option 2: Include php file in your script

```
require 'vendor/bin/interceptor.php';
```

Use it only for debug environment.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance40

Moderate activity, may be stable

Popularity34

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity72

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

Recently: every ~44 days

Total

22

Last Release

501d ago

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

1.0.16PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/96848e13a893f3d4c72217339b466debf9fd6c363cd79c3b0312ac69d34fe95d?d=identicon)[sanprojects](/maintainers/sanprojects)

---

Top Contributors

[![sanprojects](https://avatars.githubusercontent.com/u/7497442?v=4)](https://github.com/sanprojects "sanprojects (5 commits)")

---

Tags

phpcurldebugpdoredismysqliintercept

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[stefangabos/zebra_curl

A high performance solution for making multiple HTTP requests concurrently, asynchronously from your PHP projects using cURL

21971.3k2](/packages/stefangabos-zebra-curl)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.0k](/packages/ismaeltoe-osms)

PHPackages © 2026

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