Browse project documentation

Abzar overview

Abzar0.8.1View sourceEnglish / Persian

Persian utilities for PHP, with a quick start and links to every guide.

Abzar provides framework-independent Iranian validators, Persian text and digit tools, formatters, and money value objects. It requires PHP 8.1+ and mbstring, with no third-party Composer runtime dependencies. intl is optional for collation and NFC. See installation.

Quick start

After installing, save this as example.php beside vendor/ and run php example.php:

<?php
require 'vendor/autoload.php';

use Eram\Abzar\Validation\PhoneNumber;
use Eram\Abzar\Money\Amount;
use Eram\Abzar\Money\Currency;

$phone = PhoneNumber::from('+98 912 123 4567');
echo $phone->value(), "\n";
echo Currency::format(Amount::fromRials(12_345)), "\n";
09121234567
۱،۲۳۴.۵ تومان

The displayed amount keeps the five-rial remainder. Amount::inToman() would return only the integer toman portion. Invalid input to PhoneNumber::from() throws; use validate() for form errors. See money and validation.

Choose a guide

Feature matrix

NamespaceClassWhat it does
ValidationNationalIdIranian national-ID checksum + city / province lookup
ValidationLegalId11-digit Iranian legal-entity ID checksum
ValidationPhoneNumberIranian mobile + landline number validation, operator / area-code detection (09xx, +98, 0098, 98)
ValidationCardNumber16-digit bank card Luhn check + bank name from BIN
ValidationIbanIR-prefixed IBAN mod-97 check + bank lookup
ValidationPostalCode10-digit Iranian postal code validator
ValidationBillIdشناسه قبض / شناسه پرداخت mod-11 pair validator with bill-type decoding
ValidationPlateNumberIranian license plate (NN[letter]NNN-NN) parser with letter-derived type + province lookup
ValidationErrorCodeStable DOMAIN.REASON codes emitted by every validator + format exception
ValidationBank / Operator / Province / PlateTypeTyped enums with fromPersian() lookup and Arabic-char-tolerant matching
ValidationValidationResultShared {isValid, errors, errorCodes, warnings, detail} return type (implements JsonSerializable / Stringable)
Validation\DetailsValidationDetailMarker interface for the per-validator readonly DTOs returned from ValidationResult::detail()
FormatNumberFormatterThousands-separator formatter with digit normalization
FormatNumberToWordsInteger / float to Persian words (۱۲۳۴ → یک هزار و دویست و سی و چهار)
FormatWordsToNumberParse Persian number words back to int / float
FormatOrdinalNumberPersian ordinals: toWord(3) → سوم, toShort(43) → ۴۳ام
FormatTimeAgoFuzzy relative time in Persian (۵ دقیقه پیش, حدود ۳ روز پیش)
MoneyAmountImmutable Iranian-currency value object; stores rials internally, factories / accessors for both units
MoneyCurrency / UnitToman / Rial formatter and ×10 / ÷10 converter
TextScriptisPersian / hasPersian / isArabic / hasArabic detectors
TextSlugPersian-aware slug (سلام دنیا → سلام-دنیا)
TextCharNormalizerArabic → Persian char + digit normalization, HTML-aware normalizeContent(), opt-in hamza / tashkeel / kashida / NFC flags
TextKeyboardFixerSwap between English QWERTY and Persian keyboard layouts, with a detect() heuristic
TextPersianCollatorext-intl-backed fa_IR collator with sort / sortBy helpers
TextHalfSpaceFixerBest-effort zero-width-non-joiner placement for compound-word affixes (می‌روم, خانه‌ها, بزرگ‌ترین)
DigitsDigitConvertertoPersian / toEnglish / toArabic + HTML-aware convertContent()

Boundaries

Validators do not contact registries or payment providers and cannot establish identity, ownership, assignment, or reachability. Prefix lookups are bundled snapshots. Text normalization does not index or search documents. Abzar does not provide a Jalali calendar or framework bridges. APIs remain pre-1.0; read the stability policy.

All standalone snippets assume Composer’s autoloader has been loaded. Comments after expressions show return values; an expression alone does not print. Complete examples with a following text block print exactly that output. Framework snippets run inside the named application.

Search documentation

Search across all projects. Close this window to return to your guide.

Tab to navigate · Enter to openEsc to close