ariaieboy/laravel-persian-helpers

Add more functionality for Persian language into Laravel
2,187 1
Install
composer require ariaieboy/laravel-persian-helpers
Latest Version:2.2.0
PHP:~8.4|~8.5
Laravel:12 · 13
Older releases:11
License:MIT
Last Updated:Jun 23, 2026
Links: GitHub  ·  Packagist
Maintainer: ariaieboy

Add more functionality for Persian language into Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package will add some helpers and macros to the laravel that help you work with persian language and convert non persian character and digits to persian or vise-versa.

Requirement

This package requires php version >= 8.4 and laravel version >= 12

Installation

You can install the package via composer:

composer require ariaieboy/laravel-persian-helpers

You can publish the config file with:

php artisan vendor:publish --tag="laravel-persian-helpers-config"

Usage

Facade

    PersianHelpers::toEnglishDigit('۱۲۳۴'); // will return "1234"

    PersianHelpers::toPersianDigit('1234٥٤'); // will return "۱۲۳۴۵۴"

    PersianHelpers::toPersianLetter(',;كإأؤةۀي?'); // will return "،؛کااوههی؟"
    
    PersianHelpers::toPersian('12ي'); // will return "۱۲ی"

Str macros

    Str::toEnglishDigit('۱۲۳۴'); // will return "1234"

    Str::toPersianDigit('1234٥٤'); // will return "۱۲۳۴۵۴"

    Str::toPersianLetter(',;كإأؤةۀي?'); // will return "،؛کااوههی؟"
    
    Str::toPersian('12ي'); // will return "۱۲ی"

Middlewares

By using these middlewares all the user inputs will be converted to correct format.

use Ariaieboy\LaravelPersianHelpers\Http\Middleware\ToEnglishDigit;
use Ariaieboy\LaravelPersianHelpers\Http\Middleware\ToPersianDigit;
use Ariaieboy\LaravelPersianHelpers\Http\Middleware\ToPersianLetter;
use Ariaieboy\LaravelPersianHelpers\Http\Middleware\ToPersian;
Route::post('example1')->middleware(ToEnglishDigit::class);
Route::post('example2')->middleware(ToPersianDigit::class);
Route::post('example3')->middleware(ToPersianLetter::class);
Route::post('example4')->middleware(ToPersian::class);

Note: by default current_password,password and password_confirmation inputs are ignored and are not affected by this middleware to customize this behavior you should extend each of this middleware and change the $except property of the middleware

class MyCustomToEnglishDigitMiddleware extends \Ariaieboy\LaravelPersianHelpers\Http\Middleware\ToEnglishDigit{
    /**
    * @var array<string> 
    */
    protected array $except = [
    'title',
    'password'
];
}

Route::post('example')->middleware(MyCustomToEnglishDigitMiddleware::class);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

ariaieboy/filament-currency

Bring back laravel-money formatter for Filament Text Column

319,387 73
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

598,760,099 34,966
laravel/tinker

Powerful REPL for the Laravel framework.

507,193,856 7,441

Version History

Version Released PHP Laravel License
2.2.0 ~8.4|~8.5 ^12|^13 MIT
2.1.1 ~8.4|~8.5 ^12 MIT
2.1.0 ~8.4 ^v11.35.1|^12 MIT
2.0.0 ~8.4 ^v11.35.1 MIT
1.0.0 ~8.4 ^v11.35.1 MIT