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)040.3k↓19.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 1mo ago

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 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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

2096d 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)")[![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.2M24](/packages/s1lentium-iptools)[jalle19/php-whitelist-check

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

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

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

177813.7k6](/packages/markrogoyski-ipv4-subnet-calculator)[rlanvin/php-ip

IPv4/IPv6 manipulation library for PHP

180738.8k11](/packages/rlanvin-php-ip)[tholu/php-cidr-match

CIDRmatch is a library to match an IP to an IP range in CIDR notation (IPv4 and IPv6).

37211.1k](/packages/tholu-php-cidr-match)[longman/ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

147245.6k6](/packages/longman-ip-tools)

PHPackages © 2026

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