PHPackages                             yasser-elgammal/laravel-egypt-national-id-parser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. yasser-elgammal/laravel-egypt-national-id-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

yasser-elgammal/laravel-egypt-national-id-parser
================================================

A package to parse egyptian national id number.

v2.0.0(3w ago)07MITPHPPHP ^8.1

Since Feb 25Pushed 3w ago1 watchersCompare

[ Source](https://github.com/YasserElgammal/laravel-egypt-national-id-parser)[ Packagist](https://packagist.org/packages/yasser-elgammal/laravel-egypt-national-id-parser)[ RSS](/packages/yasser-elgammal-laravel-egypt-national-id-parser/feed)WikiDiscussions main Synced today

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

Laravel Egypt National ID Parser
================================

[](#laravel-egypt-national-id-parser)

A Laravel package to parse and validate Egyptian National ID numbers, extracting details such as birth date, gender, and governorate.

📌 Features
----------

[](#-features)

- Validate Egyptian National ID numbers (including **Modulo 11 check digit verification**)
- Extract birth date, gender, and governorate into a fully typed DTO (`NationalIdData`)
- Custom Laravel Validation Rule
- Supports Arabic and English translations

📦 Installation
--------------

[](#-installation)

Require the package via Composer:

```
composer require yasser-elgammal/laravel-egypt-national-id-parser
```

Publish the configuration and translation files:

```
php artisan vendor:publish --tag=laravel-egypt-national-id-parser-config
php artisan vendor:publish --tag=laravel-egypt-national-id-parser-translations
```

⚙️ Configuration
----------------

[](#️-configuration)

The configuration file `config/national-id.php` allows customization of the package settings, including the default language.

🛠 Usage
-------

[](#-usage)

### 1. Using Custom Validation Rule

[](#1-using-custom-validation-rule)

The easiest way to use the package is through the provided validation rule:

```
use YasserElgammal\LaravelEgyptNationalIdParser\Rules\EgyptianNationalId;

$request->validate([
    'national_id' => ['required', 'string', new EgyptianNationalId()],
]);
```

### 2. Parsing to Data Transfer Object (DTO)

[](#2-parsing-to-data-transfer-object-dto)

You can parse an ID into a `NationalIdData` object which provides strongly-typed methods:

```
use YasserElgammal\LaravelEgyptNationalIdParser\Facades\NationalId;

$idNumber = '29001010112341';
$data = NationalId::parse($idNumber);

if ($data) {
    echo $data->getBirthDate()->format('Y-m-d'); // Carbon instance
    echo $data->getAge(); // int
    echo $data->getGenderLabel(); // string (Male/Female)
    echo $data->getGovernorateLabel(); // string
    echo $data->getCheckDigit(); // string
}
```

To throw an exception if the ID is invalid instead of returning `null`:

```
use YasserElgammal\LaravelEgyptNationalIdParser\Exceptions\InvalidNationalIdException;

try {
    $data = NationalId::parseOrFail($idNumber);
} catch (InvalidNationalIdException $e) {
    return response()->json(['errors' => $e->getErrors()], 422);
}
```

### 3. Validating an ID Number (Legacy Array Response)

[](#3-validating-an-id-number-legacy-array-response)

If you prefer working with arrays:

```
use YasserElgammal\LaravelEgyptNationalIdParser\Facades\NationalId;

$result = NationalId::validate($idNumber);

return response()->json([
    'status' => $result['status'], // boolean
    'data' => $result['data'] ?? null, // array of components
    'errors' => $result['errors'] ?? [] // array of validation errors
]);
```

You can also customize the returned language (default is 'en'):

```
$result = NationalId::setLanguage('ar')->validate($idNumber);
```

📝 License
---------

[](#-license)

This package is open-source and licensed under the [MIT License](LICENSE.md).

🙌 Contributions
---------------

[](#-contributions)

Contributions are welcome! Feel free to submit a pull request or report issues.

📬 Contact
---------

[](#-contact)

For any questions, reach out via GitHub Issues or contact me directly.

###  Health Score

41

↑

FairBetter than 87% of packages

Maintenance96

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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.

###  Release Activity

Cadence

Every ~157 days

Total

4

Last Release

21d ago

Major Versions

1.x-dev → 2.x-dev2026-06-13

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/35766609?v=4)[Yasser Elgammal](/maintainers/YasserElgammal)[@YasserElgammal](https://github.com/YasserElgammal)

---

Top Contributors

[![YasserElgammal](https://avatars.githubusercontent.com/u/35766609?v=4)](https://github.com/YasserElgammal "YasserElgammal (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yasser-elgammal-laravel-egypt-national-id-parser/health.svg)

```
[![Health](https://phpackages.com/badges/yasser-elgammal-laravel-egypt-national-id-parser/health.svg)](https://phpackages.com/packages/yasser-elgammal-laravel-egypt-national-id-parser)
```

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M307](/packages/laravel-horizon)[spatie/laravel-sitemap

Create and generate sitemaps with ease

2.6k16.6M147](/packages/spatie-laravel-sitemap)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.8M75](/packages/spatie-laravel-honeypot)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M7](/packages/propaganistas-laravel-disposable-email)

PHPackages © 2026

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