PHPackages                             danbettles/defence - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. danbettles/defence

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

danbettles/defence
==================

A simple intrusion detection/prevention system framework for PHP apps

v10.0.0(2y ago)61.5k—0%2ISCPHPPHP ^8.1

Since Apr 27Pushed 2y ago1 watchersCompare

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

READMEChangelog (4)Dependencies (7)Versions (5)Used By (0)

Defence
=======

[](#defence)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0d72da5782d1cf80bb4dfa52b8073edad4ca58aa7b78646559367c00010627c4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616e626574746c65732f646566656e63652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/danbettles/defence/?branch=main) [![Code Coverage](https://camo.githubusercontent.com/2b4fde71a0a405248c50ba61dc0e0b1153d8d0d26aca478a1363d6627c50d5f4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616e626574746c65732f646566656e63652f6261646765732f636f7665726167652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/danbettles/defence/?branch=main) [![Build Status](https://camo.githubusercontent.com/df309826acba8a8350319ab62797037892f150c318df19d7774e0697fbb4ab0c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616e626574746c65732f646566656e63652f6261646765732f6275696c642e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/danbettles/defence/build-status/main)

A simple intrusion detection/prevention system framework written in PHP.

Defence is used principally to:

1. 🛡️ Prevent a suspicious-looking request getting deeper into an application's code and potentially exploiting vulnerabilities.
2. 🌱 Avoid wasting further system resources on unfriendly user activity.

Recently, we have found Defence to be been extremely helpful in quickly mitigating the effects of *overzealous* bots, particularly those involved in information-gathering for AI. Excessive and/or faulty requests can negatively affect the experience of other users of the system and waste resources—including electricity.

Warning

**Defence does not eliminate the need to filter user-input in your application.** While some of the included filters do indeed validate user input, they take a very high-level view. Their aim is to detect *obviously* suspect values given a very basic understanding of what they're looking at. For example, the included ID-parameter filter knows only that certain parameters must contain only digits or a blank; the filter is useful because it can quickly and easily prevent SQL injection, but the value may still be invalid as far as your app is concerned.

We recommend you read [Architecture](doc/architecture.md) before [Getting Started](doc/getting-started.md). Otherwise, [the documentation starts here](doc/README.md).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 78.6% 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 ~235 days

Total

4

Last Release

776d ago

Major Versions

v8.0.1 → v9.0.02023-11-27

v9.0.0 → v10.0.02024-04-02

PHP version history (2 changes)v8.0.0PHP ^7.4|^8.0

v10.0.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![danbettles](https://avatars.githubusercontent.com/u/736672?v=4)](https://github.com/danbettles "danbettles (11 commits)")[![RichAtPowderBlue](https://avatars.githubusercontent.com/u/47561048?v=4)](https://github.com/RichAtPowderBlue "RichAtPowderBlue (3 commits)")

---

Tags

crackingcracking-attemptsfirewallintrusion-detectionintrusion-detection-systemintrusion-preventionintrusion-prevention-systemmalicious-requestssql-injectionsql-injection-attackssuspicious-requestsrequestloggingvalidationinjectionidsfilterhackintrusionipsmaliciouspreventioncracksuspicious

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/danbettles-defence/health.svg)

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

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M273](/packages/sentry-sentry)[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[nelmio/js-logger-bundle

Adds logging of JS errors in your Symfony application

1761.2M](/packages/nelmio-js-logger-bundle)[open-telemetry/api

API for OpenTelemetry PHP.

1933.0M214](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2322.9M248](/packages/open-telemetry-sdk)[honeybadger-io/honeybadger-php

Honeybadger PHP library

381.5M4](/packages/honeybadger-io-honeybadger-php)

PHPackages © 2026

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