PHPackages                             sohophp/security - 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. sohophp/security

ActiveLibrary

sohophp/security
================

A PHP class that avoids violent attacks 一个规避暴力攻击的PHP类

v2.0.1(4y ago)112MITPHPPHP &gt;=8.1.0

Since Feb 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/sohophp/security)[ Packagist](https://packagist.org/packages/sohophp/security)[ Docs](https://www.sohophp.app)[ RSS](/packages/sohophp-security/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (8)Used By (0)

Sohophp/Security
================

[](#sohophpsecurity)

介绍
--

[](#介绍)

帮助防止暴力破解，暴力攻击 的PHP类 限制单页每秒请求数和站点每秒请求数

安装方法
----

[](#安装方法)

```
composer require sohophp/security
```

使用方法
----

[](#使用方法)

```
$dos = new Sohophp\Security\Dos();
$dos->run();
```

修改配置方法
------

[](#修改配置方法)

```
$config = new Sohophp\Security\DosConfig();
//开启调试消息
$config->setDebug(true);
//开启详情记录
$config->setSpread(true);
//添加IP白名单
$config->addWhiteList('::1','127.0.0.1');
//单页每秒最大请求数
$config->setPageCount(3);
//站点每秒请求数
$config->setSiteCount(100);
//加入黑名单秒数，每次请求重置拉黑时间
$config->setBlockingPeriod(30);
//监听全部METHOD
//$config->setListenMethods(["ANY"]);
//监听以下METHOD
$config->setListenMethods(["POST","DELETE","PUT","OPTIONS"]);
$dos = new Sohophp\Security\Dos($config);
//自动运行，阻止时出现403
//$dos->run();
//测试使用
try{
    if($dos->refused()){
        echo '';
        print_r($dos->getDebugMessages());
        echo '';
        die("已被拉黑");
    }
}catch (Exception $exception){
    die($exception->getMessage());
}
```

### 测试方法

[](#测试方法)

连续刷新同一网址

### change log

[](#change-log)

- 2021/12/23 升级到PHP8.1
-

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

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

Recently: every ~77 days

Total

7

Last Release

1607d ago

Major Versions

v1.3.5 → v2.0.02021-12-23

PHP version history (3 changes)v1.0.1PHP ^7.2

v2.0.0PHP ^8.1.0

v2.0.1PHP &gt;=8.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0066452c6da8ec15a53c67d4e3594c3d5af27f675357decf05a486ad7cee61d7?d=identicon)[sohophp](/maintainers/sohophp)

---

Top Contributors

[![sohophp](https://avatars.githubusercontent.com/u/18595011?v=4)](https://github.com/sohophp "sohophp (14 commits)")

### Embed Badge

![Health badge](/badges/sohophp-security/health.svg)

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

PHPackages © 2026

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