PHPackages                             alexeevdv/yii2-ip-validator - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. alexeevdv/yii2-ip-validator

ActiveYii2-extension[Validation &amp; Sanitization](/categories/validation)

alexeevdv/yii2-ip-validator
===========================

Yii2 IP address validator

11231PHP

Since Sep 22Pushed 10y ago1 watchersCompare

[ Source](https://github.com/alexeevdv/yii2-ip-validator)[ Packagist](https://packagist.org/packages/alexeevdv/yii2-ip-validator)[ RSS](/packages/alexeevdv-yii2-ip-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

yii2-ip-validator
=================

[](#yii2-ip-validator)

Yii2 ip address validator. Can check that IP address is valid or in given range

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ php composer.phar require alexeevdv/yii2-ip-validator "dev-master"

```

or add

```
"alexeevdv/yii2-ip-validator": "dev-master"

```

to the `require` section of your `composer.json` file.

Usage
-----

[](#usage)

```
public function rules() {
    return [
        //...
        ['ip', \alexeevdv\ip\Validator::className(), "range" => [
            "192.168.1.1",
            "10.62.15.0/24",
            "109.232.0.0/16"
        ]],
        //...
    ];
}

// or

$validator = new \alexeevdv\ip\Validator([
    "allowPrivate" => false,
    "allowReserved" => false,
]);

$validator->validate("127.0.0.1"); // false
```

Params
------

[](#params)

```
/**
 * Allow private ip addresses?
 * 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16
 */
bool $allowPrivate = true;

/**
 * Allow reserved ip addresses?
 * 0.0.0.0/8, 169.254.0.0/16, 192.0.2.0/24 and 224.0.0.0/4
 */
bool $allowReserved = true;

/**
 * Range of allowed ip addresses. Array of subnets and ip addresses.
 */
array $range = [];
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

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

---

Top Contributors

[![alexeevdv](https://avatars.githubusercontent.com/u/597839?v=4)](https://github.com/alexeevdv "alexeevdv (5 commits)")

### Embed Badge

![Health badge](/badges/alexeevdv-yii2-ip-validator/health.svg)

```
[![Health](https://phpackages.com/badges/alexeevdv-yii2-ip-validator/health.svg)](https://phpackages.com/packages/alexeevdv-yii2-ip-validator)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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