PHPackages                             rtckit/pcap-ffi - 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. rtckit/pcap-ffi

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

rtckit/pcap-ffi
===============

PHP Packet Capture via libpcap through FFI

0.6.5(5y ago)9761[2 PRs](https://github.com/rtckit/php-pcap-ffi/pulls)MITPHPPHP &gt;=7.4.0

Since Sep 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/rtckit/php-pcap-ffi)[ Packagist](https://packagist.org/packages/rtckit/pcap-ffi)[ Docs](https://github.com/rtckit/php-pcap-ffi)[ RSS](/packages/rtckit-pcap-ffi/feed)WikiDiscussions master Synced 3w ago

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

PHP Packet Capture via FFI
==========================

[](#php-packet-capture-via-ffi)

Stream driven PHP packet capture library, leveraging libpcap via FFI.

[![Build Status](https://camo.githubusercontent.com/5fe2dd4b32b3e66917978255a00d76403066fbc715210c06fc9071ef8f7c835d/68747470733a2f2f7472617669732d63692e636f6d2f7274636b69742f7068702d706361702d6666692e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/rtckit/php-pcap-ffi)[![Latest Stable Version](https://camo.githubusercontent.com/e85bdc67a67b55c34bfd25c94ad1c1a423b39ba69432acde4e33b8c3b8facfe0/68747470733a2f2f706f7365722e707567782e6f72672f7274636b69742f706361702d6666692f762f737461626c652e706e67)](https://packagist.org/packages/rtckit/pcap-ffi)[![Maintainability](https://camo.githubusercontent.com/6685041be2846644e9a7df4ef7c50fef3c9b1ec82c4a8c4faef0c055c8f99bda/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f65386332646361383030373435353362613536312f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/rtckit/php-pcap-ffi/maintainability)[![License](https://camo.githubusercontent.com/b8cadaa967891081f8f165695470689986c028821dd8a040132f6e661795dc0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c7565)](LICENSE)

Pcap Extension
--------------

[](#pcap-extension)

Whenever possible (or if using an older version of PHP), you should use the native [pcap PHP extension](https://github.com/rtckit/php-pcap-ext), this library is provided as an alternative to it for select/edge cases. Otherwise, the FFI based packet capture library is fully compatible with the `pcap` extension. As a result, all changes applied to the extension are reflected here too, and the library version will always match its extension counterpart.

Requirements
------------

[](#requirements)

This library makes use of features introduced as of PHP 7.4, it will not work with obsolete versions. Of course, the [PHP FFI extension](https://www.php.net/manual/en/book.ffi.php) must be installed and enabled.

The libpcap library must be installed on the target environment; some Linux distributions meddle with the library naming protocols and this can confuse the FFI initialization process. Should that be the case, one can set the `LIBPCAP_NAME` environment variable to the actual library name, or even the absolute path to the library's .so file for custom builds or non-standard directory layouts.

For example, for Debian Buster, one would set `LIBPCAP_NAME` to `libpcap.so.1.8.1`.

Install
-------

[](#install)

The recommended way to install this library is [through Composer](https://getcomposer.org). [New to Composer?](https://getcomposer.org/doc/00-intro.md)

This will install the latest supported version:

```
composer require rtckit/pcap-ffi:^0.6.5
```

Tests
-----

[](#tests)

Before running the test suite, make sure the user has the ability to capture network packets (root or `CAP_NET_RAW`).

```
make test
```

License
-------

[](#license)

MIT, see [LICENSE file](LICENSE).

### Acknowledgments

[](#acknowledgments)

- [libpcap](https://github.com/the-tcpdump-group/libpcap) by The Tcpdump Group, BSD licensed.

### Contributing

[](#contributing)

Bug reports (and small patches) can be submitted via the [issue tracker](https://github.com/rtckit/php-pcap-ffi/issues). Forking the repository and submitting a Pull Request is preferred for substantial patches.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.8% 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 ~24 days

Total

3

Last Release

2072d ago

PHP version history (2 changes)0.6.2PHP ^7.4

0.6.4PHP &gt;=7.4.0

### Community

Maintainers

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

---

Top Contributors

[![cdosoftei](https://avatars.githubusercontent.com/u/7636091?v=4)](https://github.com/cdosoftei "cdosoftei (9 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (2 commits)")

---

Tags

ffinetwork-securitypacket-capturepacket-snifferpcapphp-librarycapturepacketpcaplibpcaptcpdump

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rtckit-pcap-ffi/health.svg)

```
[![Health](https://phpackages.com/badges/rtckit-pcap-ffi/health.svg)](https://phpackages.com/packages/rtckit-pcap-ffi)
```

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M6.8k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M89](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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