Download the PHP package zarbinco/laravel-persian-core without Composer

On this page you can find all versions of the php package zarbinco/laravel-persian-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-persian-core

Laravel Persian Core

Tests Latest Version on Packagist Total Downloads

zarbinco/laravel-persian-core is a lightweight Persian/Iranian utility foundation for Laravel applications.

It handles text normalization, digit conversion, mobile normalization, money helpers, validation rules, and offline bank/card/Sheba detection. It gives Laravel applications a small, dependency-light base for common Persian and Iranian input handling without bundling business-specific features.

Read this README in Persian.

Features

What This Package Is Not

This core package intentionally does not include:

Validation vs Normalization

Normalizers are designed for cleanup, formatting, conversion, and predictable storage/display/search output. Some normalizers may be permissive because they are useful for extracting or cleaning messy user input.

Validators are designed for Laravel validation. They validate shape, required structure, and checksums where applicable. They do not prove real-world ownership, account existence, operator ownership, card status, or live banking status.

Use normalizers when you need normalized output. Use validation rules when you need to reject invalid input. Combine validation rules with Laravel's required rule when a field must be present.

Bank Detection Boundaries

Bank/card/Sheba detection is offline and best-effort. It uses local metadata for Iranian card BIN/IIN values and Sheba bank codes, and unknown banks return null.

Bank detection does not prove:

Use IranianCardNumber and IranianSheba validation rules when validation is needed. Even then, validation is limited to shape and checksum checks where applicable, not live banking verification.

Compatibility

Compatibility is based on composer.json:

Installation

Laravel package discovery registers the service provider and facade automatically.

Publishing

Publish the package config:

Publish validation translations:

Or use the package installer to publish both:

Use --force when you intentionally want to overwrite previously published files.

Quick Usage

Text

Text normalization converts Arabic Yeh and Kaf to Persian Yeh and Kaf, removes Arabic diacritics and tatweel, removes problematic invisible characters while preserving ZWNJ, and normalizes whitespace.

normalize() and text-only forStorage() stay conservative. forDisplay() applies display-friendly punctuation cleanup. forSearch() applies more aggressive search normalization such as punctuation removal and configurable ZWNJ handling.

Numbers

The number normalizer focuses on digit conversion. Number parsing helpers clean formatted input for numeric use.

Normalization Pipeline

Persian::clean() is an alias for storage normalization. Storage and display digit output are config-driven.

Search Normalization

Search normalization prepares deterministic text for indexing and user-query matching. It normalizes Persian/Arabic letter variants, removes diacritics and tatweel, handles ZWNJ according to config, converts Persian and Arabic digits to English, removes punctuation by default, and collapses digit groups.

Persian::searchable($value) is kept as a direct string helper and uses the same search normalizer:

This is normalization for search/indexing. It is not a full-text search engine, stemming system, transliteration layer, fuzzy matcher, Scout integration, or database-specific ranking tool.

Mobile

Mobile helpers normalize Iranian mobile numbers and format them in national or international forms.

The default mask can be changed with mobile.iran.mask_pattern. Invalid masks fall back safely to 0912***4567.

Money

Money helpers parse and format toman/rial values. They are not accounting, tax, invoice, or payment tools.

The default conversion rate is 1 toman = 10 rial and can be changed through money.rial_to_toman_rate.

Bank Detection

Bank detection provides best-effort metadata from Iranian card BIN/IIN values and Sheba bank codes. It is offline-only, does not call external services, and unknown banks return null.

Direct helpers are available when you only need the bank object:

Bank detection is not validation and does not prove ownership, existence, account status, or card/account convertibility. Use IranianCardNumber and IranianSheba validation rules when validation is needed.

Validation

The package includes Laravel validation Rule objects. Empty values pass by default, so combine these rules with Laravel's required rule when a field must be present.

Available rules:

Validation boundaries:

Strict Validation Mode

Validators are strict by default. Strict mode rejects values that only contain a valid value inside surrounding text, while normalizers remain permissive for extraction and cleanup use cases.

For legacy behavior, disable strict validation globally or per rule:

Strict validation still accepts Persian, Arabic, and English digits plus common separators for full values such as 0912-123-4567, 6037 9900 0000 0006, IR18 0100 0000 0000 0000 0000 00, and ۱,۲۵۰,۰۰۰ تومان.

Artisan Commands

persian-core:doctor checks common setup and configuration mistakes. persian-core:about prints package, environment, config, module, and command information.

Configuration

The default config is published to config/persian-core.php.

numbers.storage_digits controls storage normalization:

numbers.display_digits controls display normalization:

Defaults are storage_digits: en and display_digits: fa. Unsupported digit modes fall back safely to those defaults.

Other notable config groups:

Extending / Overriding Services

Core services are bound to small contracts so applications can override implementation details through Laravel's container:

Custom implementations should preserve the documented behavior and return types expected by the contract. Bank detection remains offline metadata-based unless your application explicitly replaces it with its own service.

Testing / Quality

Available Composer quality commands:

composer test runs PHPUnit. composer analyse runs PHPStan/Larastan. composer format -- --test runs Pint in check mode. composer lint runs Composer validation, PHPStan, and PHPUnit.

Contributing

Please see CONTRIBUTING.md for local setup, coding style, and pull request expectations.

Security

Please see SECURITY.md for supported versions and vulnerability reporting.

License

The MIT License (MIT). See LICENSE.md.


All versions of laravel-persian-core with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/validation Version ^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zarbinco/laravel-persian-core contains the following files

Loading the files please wait ...