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

ActiveLibrary

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

PHP Packet Capture via libpcap through FFI

0.6.5(5y ago)10761[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 5d 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 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

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

2024d 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

[microweber/screen

A PHP Class to interact with PhantomJs and capture screenshot of a webpage

632226.0k1](/packages/microweber-screen)[payum/core

One million downloads of Payum already! Payum offers everything you need to work with payments. Friendly for all PHP frameworks (Symfony, Laravel, Laminas, Yii, Silex). Check more visiting site.

484.8M173](/packages/payum-core)[cybercog/laravel-paket

Composer personal web interface. Manage Laravel dependencies without switching to command line!

1753.3k](/packages/cybercog-laravel-paket)[urlbox/screenshots

Use urlbox to easily generate website thumbnail screenshots from a URL

14250.4k](/packages/urlbox-screenshots)

PHPackages © 2026

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