PHPackages                             nakanakaii/countries - 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. nakanakaii/countries

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

nakanakaii/countries
====================

This package is a user-friendly Laravel package that provides a list of countries along with their codes, flags, phone number lengths, and shortcodes. It simplifies the process of accessing country-related information, making it easy for developers to integrate into their applications.

v1.1.0(5mo ago)727.8k↑23.1%11MITPHPPHP &gt;=8.0.0CI passing

Since Nov 13Pushed 4mo ago3 watchersCompare

[ Source](https://github.com/nakanakaii/countries)[ Packagist](https://packagist.org/packages/nakanakaii/countries)[ Docs](https://github.com/nakanakaii/countries)[ RSS](/packages/nakanakaii-countries/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (1)

Countries
=========

[](#countries)

[![Packagist Version](https://camo.githubusercontent.com/874f1f60dda6d6121dcaba72fef35c38aff53f106f70591dde6cd2d4526f92d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e616b616e616b6169692f636f756e7472696573)](https://camo.githubusercontent.com/874f1f60dda6d6121dcaba72fef35c38aff53f106f70591dde6cd2d4526f92d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e616b616e616b6169692f636f756e7472696573)[![Packagist Downloads](https://camo.githubusercontent.com/a883c6f035f9231a555deb2be331830858abda72c2465b32b43da219dfc0a2e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e616b616e616b6169692f636f756e7472696573)](https://camo.githubusercontent.com/a883c6f035f9231a555deb2be331830858abda72c2465b32b43da219dfc0a2e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e616b616e616b6169692f636f756e7472696573)[![License](https://camo.githubusercontent.com/f26e8a561942663904a77d547542360181409de5efdd5c538058894dd1fcb1f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e616b616e616b6169692f636f756e7472696573)](https://camo.githubusercontent.com/f26e8a561942663904a77d547542360181409de5efdd5c538058894dd1fcb1f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e616b616e616b6169692f636f756e7472696573)[![PHP Version](https://camo.githubusercontent.com/d7a1db7eb245fb708fe56bea040cff60272599eb7e2cd5f0c4d32f9597eaa97b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6e616b616e616b6169692f636f756e7472696573)](https://camo.githubusercontent.com/d7a1db7eb245fb708fe56bea040cff60272599eb7e2cd5f0c4d32f9597eaa97b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6e616b616e616b6169692f636f756e7472696573)[![GitHub Stars](https://camo.githubusercontent.com/b4c9ac616a85d5a2fb66f21a98f5d2c1e0660f2ba9ff1e9b049bc02c905b31b2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6e616b616e616b6169692f636f756e74726965733f7374796c653d736f6369616c)](https://camo.githubusercontent.com/b4c9ac616a85d5a2fb66f21a98f5d2c1e0660f2ba9ff1e9b049bc02c905b31b2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6e616b616e616b6169692f636f756e74726965733f7374796c653d736f6369616c)[![GitHub Issues](https://camo.githubusercontent.com/22b670d0a940949674934c59cdc48e7ee17c07a0974f9cb309b518fdc6cc6f18/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6e616b616e616b6169692f636f756e7472696573)](https://camo.githubusercontent.com/22b670d0a940949674934c59cdc48e7ee17c07a0974f9cb309b518fdc6cc6f18/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6e616b616e616b6169692f636f756e7472696573)[![Last Commit](https://camo.githubusercontent.com/0cb0c54baa1092364c345c6fd6470f308e031395a17e87f9d582abf64771d208/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f6e616b616e616b6169692f636f756e7472696573)](https://camo.githubusercontent.com/0cb0c54baa1092364c345c6fd6470f308e031395a17e87f9d582abf64771d208/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f6e616b616e616b6169692f636f756e7472696573)

This package is a user-friendly Laravel package that provides a list of countries along with their codes, flags, phone number lengths, and shortcodes. It simplifies the process of accessing country-related information, making it easy for developers to integrate into their applications.

- [Countries](#countries)
    - [Installation](#installation)
    - [Usage](#usage)
        - [Get all countries](#get-all-countries)
        - [Get a specific country by name](#get-a-specific-country-by-name)
        - [Get a specific country by code](#get-a-specific-country-by-code)
        - [Get a specific country by dial code](#get-a-specific-country-by-dial-code)
        - [Get the validator rules for a country by code](#get-the-validator-rules-for-a-country-by-code)
        - [Get the validator rules for a country by dial code](#get-the-validator-rules-for-a-country-by-dial-code)
    - [Troubleshooting and Data Correction](#troubleshooting-and-data-correction)

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

[](#installation)

To install the package, use the following command:

```
composer require nakanakaii/countries
```

Also, publish the flags to your application's public folder.

```
php artisan vendor:publish --tag=countries-flags
```

Finally, you can import it in your code:

```
use Nakanakaii\Countries\Countries;
```

Usage
-----

[](#usage)

### Get all countries

[](#get-all-countries)

To retrieve a list of all countries, use the following code:

```
Countries::all()
```

The `all()` method returns an array of country objects, each containing the following information:

- `name`: The name of the country (e.g., "Japan").
- `code`: The ISO 3166-1 alpha-2 code of the country (e.g., "JP").
- `flag`: The flag of the country as emoji (e.g., "🇯🇵").
- `dialCode`: The international dialing code for the country (e.g., "81").
- `regionCode`: Short region code (e.g., "AS").
- `timezones`: An array of timezone offsets or identifiers (e.g., \[9\]).
- `languages`: An array of language names spoken in the country (e.g., \["Japanese"\]).
- `languageCodes`: An array of language ISO codes (e.g., \["ja"\]).
- `region`: Human-readable region name (e.g., "Asia").
- `currencyCode`: The ISO currency code used in the country (e.g., "JPY").
- `minLength`: The minimum length of the local phone number (e.g., 10).
- `maxLength`: The maximum length of the local phone number (e.g., 10)

### Get a specific country by name

[](#get-a-specific-country-by-name)

To find a specific country by its name, use the `findByName()` method:

```
Countries::findByName('United Arab Emirates')
```

The `findByName()` method accepts the country name as a parameter and returns the country object that matches the provided name.

### Get a specific country by code

[](#get-a-specific-country-by-code)

To find a specific country by its code, use the `findByCode()` method:

```
Countries::findByCode('AE')
```

The `findByCode()` method accepts the country code (ISO 3166-1 alpha-2 code) as a parameter and returns the country object that matches the provided code.

### Get a specific country by dial code

[](#get-a-specific-country-by-dial-code)

To find a specific country by its dial code, use the `findByDialCode()` method:

```
Countries::findByDialCode('971')
```

The `findByDialCode()` method accepts the country dial code as a parameter and returns the country object that matches the provided dial code.

### Get the validator rules for a country by code

[](#get-the-validator-rules-for-a-country-by-code)

To retrieve the validator rules for a specific country by its code, use the `getPhoneValidatorByCode()` method:

```
Countries::getPhoneValidatorByCode('AE')
```

### Get the validator rules for a country by dial code

[](#get-the-validator-rules-for-a-country-by-dial-code)

To retrieve the validator rules for a specific country by its dial code, use the `getPhoneValidatorByDialCode()` method:

```
Countries::getPhoneValidatorByDialCode('971')
```

The `getPhoneValidatorByDialCode()` method accepts the country dial code as a parameter and returns the validator rules for phone numbers in that country.

> NOTE: The validator rules returned by the getPhoneValidatorByCode() and getPhoneValidatorByDialCode() methods are in the form of regular expressions that can be used for phone number validation.

---

Feel free to explore the package and utilize the provided methods according to your application's requirements.

Troubleshooting and Data Correction
-----------------------------------

[](#troubleshooting-and-data-correction)

If you encounter any issues or have any suggestions or find any incorrect or missing data, please feel free to [open an issue](https://github.com/nakanakaii/countries/issues/new/choose) on GitHub.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance73

Regular maintenance activity

Popularity34

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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 ~188 days

Total

5

Last Release

164d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/64766361?v=4)[Ahmed D. ALi](/maintainers/nakanakaii)[@nakanakaii](https://github.com/nakanakaii)

---

Top Contributors

[![nakanakaii](https://avatars.githubusercontent.com/u/64766361?v=4)](https://github.com/nakanakaii "nakanakaii (15 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (2 commits)")[![andrii-pukhalevych](https://avatars.githubusercontent.com/u/3767063?v=4)](https://github.com/andrii-pukhalevych "andrii-pukhalevych (1 commits)")

---

Tags

countriesflagslaravelphone-number-lengthvalidation

### Embed Badge

![Health badge](/badges/nakanakaii-countries/health.svg)

```
[![Health](https://phpackages.com/badges/nakanakaii-countries/health.svg)](https://phpackages.com/packages/nakanakaii-countries)
```

###  Alternatives

[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[sunspikes/clamav-validator

Custom Laravel 5 anti-virus validator for file uploads.

3651.8M3](/packages/sunspikes-clamav-validator)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)

PHPackages © 2026

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