PHPackages                             kublermdk/yii2-phone-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. kublermdk/yii2-phone-validator

ActiveValidator[Validation &amp; Sanitization](/categories/validation)

kublermdk/yii2-phone-validator
==============================

Yii2 Phone validator wrapper on top of PhoneNumberUtil library also used by Android devices. This is a fork of https://github.com/udokmeci/yii2-phone-validator with an update to the giggsey/libphonenumber-for-php version

1.0.7(3y ago)07.9k↓16.7%MITPHPPHP &gt;=5.3.0

Since Mar 10Pushed 3y agoCompare

[ Source](https://github.com/kublermdk/yii2-phone-validator)[ Packagist](https://packagist.org/packages/kublermdk/yii2-phone-validator)[ Docs](https://github.com/udokmeci/yii2-beanstalk)[ RSS](/packages/kublermdk-yii2-phone-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (9)Used By (0)

yii2-phone-validator
====================

[](#yii2-phone-validator)

Yii2 phone validator is a validator uses phone number util to validate and format the phone number attribute of model.

> This is a very slightly modified version of  but with the latest giggsey/libphonenumber-for-php
>
> Created Q2 2022 and the whole reason is to add &gt;= in the requires line for the composer.json i.e `"giggsey/libphonenumber-for-php": ">=8.0"`
>
> This means there's support for newer phone numbers as giggsey/libphonenumber-for-php is up to v8.12.48 as for 2022-05-26th whilst the original udokmeci/yii2-phone-validator was stuck on v7

Note: You'll want to change from `udokmeci\yii2-phone-validator` to `kublermdk\yii2PhoneValidator` if you were using the old one.

How to use?
===========

[](#how-to-use)

\##Installation with Composer Just add the line under `require` object in your `composer.json` file. If you have issues with Composer not finding the repo, then try adding the repositories entry so it knows where to look on Github

```
{
    "require": {
        "kublermdk/yii2-phone-validator" : ">=1.0"
    },
    "repositories": [
      {
        "type": "git",
        "url": "https://github.com/kublermdk/yii2-phone-validator"
      }
    ]
}
```

then run

```
$> composer update
```

\##Configuration Now add following in to your `model` rules. ###Note: ISO 3166-1 alpha-2 codes are required for country attribute. You can use [db-regions](https://github.com/udokmeci/db-regions) for countries list.

```
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
          [['name', 'country'], 'string', 'max' => 50],
          // add this line
          [['phone'], 'kublermdk\yii2PhoneValidator\PhoneValidator'],
        ];
    }
```

\##Advanced The `country` and `country_code` attributes are tried if `country` or `countryAttribute` is not specified.

```
  // All phones will be controlled according to Turkey and formatted to TR Phone Number
  [['phone'], 'kublermdk\yii2PhoneValidator\PhoneValidator','country'=>'TR'],//

  //All phones will be controlled according to value of $model->country_code
  [['phone'], 'kublermdk\yii2PhoneValidator\PhoneValidator','countryAttribute'=>'country_code'],

  //All phones will be controlled according to value of $model->country_code
  //If model has not a country attribute then phone will not be validated
  //If phone is a valid one will be formatted for International Format. default behavior.
  [['phone'], 'kublermdk\yii2PhoneValidator\PhoneValidator','countryAttribute'=>'country_code','strict'=>false,'format'=>true],
```

Any forks are welcome.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 65% 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 ~376 days

Recently: every ~233 days

Total

8

Last Release

1447d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/907142?v=4)[Michael Kubler](/maintainers/kublermdk)[@kublermdk](https://github.com/kublermdk)

---

Top Contributors

[![udokmeci](https://avatars.githubusercontent.com/u/8896298?v=4)](https://github.com/udokmeci "udokmeci (13 commits)")[![kublermdk](https://avatars.githubusercontent.com/u/907142?v=4)](https://github.com/kublermdk "kublermdk (6 commits)")[![julianrutten](https://avatars.githubusercontent.com/u/1588481?v=4)](https://github.com/julianrutten "julianrutten (1 commits)")

---

Tags

yii2phone-numberphone number validator

### Embed Badge

![Health badge](/badges/kublermdk-yii2-phone-validator/health.svg)

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

###  Alternatives

[borales/yii2-phone-input

Yii2 International telephone numbers - Asset Bundle, Behavior, Validator, Widget

1341.6M6](/packages/borales-yii2-phone-input)[udokmeci/yii2-phone-validator

Modern Yii2 Phone validator wrapper on top of PhoneNumberUtil library also used by Android devices

36218.9k1](/packages/udokmeci-yii2-phone-validator)[codeonyii/yii2-at-least-validator

Validates at least one (or more) attributes.

28253.5k1](/packages/codeonyii-yii2-at-least-validator)[arogachev/yii2-many-to-many

Many-to-many ActiveRecord relation for Yii 2 framework

3541.2k4](/packages/arogachev-yii2-many-to-many)[yii2mod/yii2-validators

Collection of useful validators for Yii Framework 2.0

1816.8k](/packages/yii2mod-yii2-validators)

PHPackages © 2026

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