PHPackages                             etchfoda/php-whitelist-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. etchfoda/php-whitelist-check

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

etchfoda/php-whitelist-check
============================

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

1.0.9(5y ago)113912BSD-2-ClausePHPPHP &gt;=5.3.0

Since Feb 3Pushed 5y agoCompare

[ Source](https://github.com/EtchFoda/php-whitelist-check)[ Packagist](https://packagist.org/packages/etchfoda/php-whitelist-check)[ Docs](https://github.com/etchfoda/php-whitelist-check)[ RSS](/packages/etchfoda-php-whitelist-check/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (11)Used By (2)

[![Build Status](https://camo.githubusercontent.com/fe659e7ac50f49896ef38c805e4a8799ea39a5d522150acc01c17482bc3827b1/68747470733a2f2f7472617669732d63692e6f72672f4a616c6c6531392f7068702d77686974656c6973742d636865636b2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/Jalle19/php-whitelist-check)[![Coverage Status](https://camo.githubusercontent.com/3803dcca100837d7b6e68f457a59d67726cc1c09ec3e2b6da743e9664541c8de/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4a616c6c6531392f7068702d77686974656c6973742d636865636b2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Jalle19/php-whitelist-check?branch=master)

php-whitelist-check
===================

[](#php-whitelist-check)

A modern and simple approach to validating IP addresses and domains against a whitelist. 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::whitelist()` method takes an array of definitions which will constitute the whitelist. 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 whitelist. The method will return true if the value matches any of the definitions.

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

Example usage:

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

$checker = new Whitelist\Check();

try {
	$checker->whitelist(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 Whitelist\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

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~265 days

Recently: every ~446 days

Total

10

Last Release

2143d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1da9c7b76693fd6dff979ebcc864d67ea9e92fee6051a65b03959695da520331?d=identicon)[etchfoda](/maintainers/etchfoda)

---

Top Contributors

[![Jalle19](https://avatars.githubusercontent.com/u/1106133?v=4)](https://github.com/Jalle19 "Jalle19 (30 commits)")[![hesham-fouda](https://avatars.githubusercontent.com/u/15731469?v=4)](https://github.com/hesham-fouda "hesham-fouda (3 commits)")[![dialupdisaster](https://avatars.githubusercontent.com/u/157699?v=4)](https://github.com/dialupdisaster "dialupdisaster (2 commits)")

---

Tags

ipv6ipv4cidrwhitelist

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/etchfoda-php-whitelist-check/health.svg)

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

###  Alternatives

[s1lentium/iptools

PHP Library for manipulating network addresses (IPv4 and IPv6)

2446.6M28](/packages/s1lentium-iptools)[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)[zoujingli/ip2region

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

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

Handle IPv4, IPv6 addresses and ranges

3167.3M64](/packages/mlocati-ip-lib)[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)
