PHPackages                             brianlmoon/php-safelist-check - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. brianlmoon/php-safelist-check

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

brianlmoon/php-safelist-check
=============================

Provides a simple way to check whether an address or domain is on a safelist

2.0.0(5y ago)041.9k↓37.2%1BSD-2-ClausePHPPHP &gt;=5.3.0

Since Feb 3Pushed 5y agoCompare

[ Source](https://github.com/brianlmoon/php-safelist-check)[ Packagist](https://packagist.org/packages/brianlmoon/php-safelist-check)[ Docs](https://github.com/brianlmoon/php-safelist-check)[ RSS](/packages/brianlmoon-php-safelist-check/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (10)Used By (0)

php-safelist-check
==================

[](#php-safelist-check)

This is a fork of  to change hidden bias terminology.

A modern and simple approach to validating IP addresses and domains against a safelist. It supports both IPv4 and IPv6 addresses and CIDR subnets in addition to domain names and wild-card domains.

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

[](#requirements)

- PHP 5.3 or newer

Usage
-----

[](#usage)

The `Check::safelist()` method takes an array of definitions which will constitute the safelist. The definitions can either be strings (which will be parsed to their respective objects) or objects.

The `Check::check($value)` method is used to check the specified value against the current safelist. The method will return true if the value matches any of the definitions.

To create your own definition classes just extended `Safelist\Definition\Definition` and implement `Safelist\Definition\IDefinition`

Example usage:

```
require_once("vendor/autoload.php");

$checker = new Safelist\Check();

try {
	$checker->safelist(array(
		'10.0.3.1',
		'10.0.0.0/16',
		'2001:db8:100:934b::3:1',
		'2001:db8:100:934b::/64',
		'*.example.com',
		'localhost',
		new Safelist\Definition\Domain('vpn.work.com'),
	));
}
catch (InvalidArgumentException $e) {
	// thrown when an invalid definition is encountered
}

$checker->check('10.0.1.1'); // true
$checker->check('10.1.1.1'); // false
$checker->check('2001:db8:100:934b::210:2'); // true
$checker->check('another.example.com'); // true
```

License
-------

[](#license)

This library is licensed under the BSD 2-Clause License

Credits
-------

[](#credits)

This library depends on `xrstf/ip-utils` for the IP-related functionality. It also assumes that ip-utils's test cases are sufficient, which is why only trivial testing on these functions have been made for this library.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 78.9% 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 ~299 days

Recently: every ~573 days

Total

9

Last Release

2142d ago

Major Versions

1.0.7 → 2.0.02020-08-21

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/49531?v=4)[Brian Moon](/maintainers/brianlmoon)[@brianlmoon](https://github.com/brianlmoon)

---

Top Contributors

[![Jalle19](https://avatars.githubusercontent.com/u/1106133?v=4)](https://github.com/Jalle19 "Jalle19 (30 commits)")[![brianlmoon](https://avatars.githubusercontent.com/u/49531?v=4)](https://github.com/brianlmoon "brianlmoon (4 commits)")[![dialupdisaster](https://avatars.githubusercontent.com/u/157699?v=4)](https://github.com/dialupdisaster "dialupdisaster (2 commits)")[![digitalfiz](https://avatars.githubusercontent.com/u/157699?v=4)](https://github.com/digitalfiz "digitalfiz (2 commits)")

---

Tags

ipv6ipv4cidrsafelist

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/brianlmoon-php-safelist-check/health.svg)

```
[![Health](https://phpackages.com/badges/brianlmoon-php-safelist-check/health.svg)](https://phpackages.com/packages/brianlmoon-php-safelist-check)
```

###  Alternatives

[s1lentium/iptools

PHP Library for manipulating network addresses (IPv4 and IPv6)

2446.6M28](/packages/s1lentium-iptools)[zoujingli/ip2region

ip2region v3.0 for PHP - 企业级 IP 地理位置查询库，支持 IPv4 和 IPv6，多种缓存策略，零依赖，开箱即用

1.4k475.0k65](/packages/zoujingli-ip2region)[mlocati/ip-lib

Handle IPv4, IPv6 addresses and ranges

3167.3M68](/packages/mlocati-ip-lib)[jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

45796.8k4](/packages/jalle19-php-whitelist-check)[markrogoyski/ipv4-subnet-calculator

Network calculator for subnet mask and other classless (CIDR) network information.

175852.6k14](/packages/markrogoyski-ipv4-subnet-calculator)[rlanvin/php-ip

IPv4/IPv6 manipulation library for PHP

180803.8k12](/packages/rlanvin-php-ip)

PHPackages © 2026

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