yemenifree/laravel-arabic-numbers-middleware 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yemenifree/laravel-arabic-numbers-middleware

Composer 安装命令:

composer require yemenifree/laravel-arabic-numbers-middleware

包简介

auto transforms arabic/eastern to eastern/arabic numbers for i.e ١٢٣٤٥٦٧٨ to 12345678

README 文档

README

Latest Version on Packagist Software License Build Status StyleCI Coverage Status Quality Score Total Downloads

A tiny package to transforms arabic/eastern* to eastern*/arabic numbers for i.e ١٢٣٤٥٦٧٨ to 12345678 before validations to avoid invalid integers error when pass eastern numbers by (ios/mac) users

  • These numbers are known as أرقام هندية ("Indian numbers") in Arabic. They are sometimes also called "Indic numerals" in English. However, that is sometimes discouraged as it can lead to confusion with Indian numerals

Support version

Laravel laravel-modules
5.1 ^1.0
5.8 ^2.0
6.X ^2.1
8.X ^3.0
9.X ^4.0

Install

Via Composer

$ composer require yemenifree/laravel-arabic-numbers-middleware

Usage

If you do not run Laravel 5.5 (or higher), then add the service provider in config/app.php:

Yemenifree\LaravelArabicNumbersMiddleware\ServiceProvider::class,

If you do run the package on Laravel 5.5+, package auto-discovery takes care of the magic of adding the service provider.

That's it! by default package automatic transform all eastern numbers to arabic for all requests

Package includes two middleware

  • "eastern-to-arabic" to transform numbers from eastern to arabic (i.e ١٢٣ to 123)
  • "arabic-to-eastern" to transform numbers from arabic to eastern (i.e 123 to ١٢٣)

You can use middleware for custom router for example

Route::any('/login', ['middleware' => 'eastern-to-arabic', function () {
    // your code
}]);

you can ignore fields from transform by pass fields name as parameters to middleware for example

// ignore transform pass field 
Route::any('/login', ['middleware' => 'arabic-to-eastern:pass', function () {
    // your code
}]);
        
// you can also ignore multi fields
Route::any('/login', ['middleware' => 'arabic-to-eastern:pass,test', function () {
    // your code
}]);

inline ignore fields not work if auto_register_middleware enable and middleware you want to use inside auto_middleware option, instead you can set ignore fields in config file arabic-numbers-middleware.php

Optional

if you want customizes configuration you can publish the configuration

$ php artisan vendor:publish --provider="Yemenifree\LaravelArabicNumbersMiddleware\ServiceProvider"

This is the content of the published config file arabic-numbers-middleware.php:

return [
    /*
     |--------------------------------------------------------------------------
     | enable auto register middleware for all requests
     |--------------------------------------------------------------------------
     |
     | if you want auto register for custom middleware group
     |      'auto_register_middleware' => ['web'], //for web group only
     |      'auto_register_middleware' => true, //  all groups
     |      'auto_register_middleware' => false, // none
     */
    'auto_register_middleware' => true,

    /*
     |--------------------------------------------------------------------------
     | list of middleware they will register for all requests automatic by package
     |--------------------------------------------------------------------------
     |
     |  Supported Middleware: "arabic-to-eastern", "eastern-to-arabic"
     */
    'auto_middleware' => Yemenifree\LaravelArabicNumbersMiddleware\Middleware\TransformHindiToArabicNumbers::class,

    /*
     |--------------------------------------------------------------------------
     | except transform fields ( POST | GET ) from all middleware
     |--------------------------------------------------------------------------
     |
     | all none string value will be ignore by default, you can ignore fields by name (key) of POST or GET
     |
    */
    'except_from_all' => [
        // 'login'
    ],

    /*
     |--------------------------------------------------------------------------
     | except transform fields ( POST | GET ) from eastern to arabic
     |--------------------------------------------------------------------------
     |
     | all none string value will be ignore by default, you can ignore fields by name (key) of POST or GET
     |
     */
    'except_from_eastern_to_arabic' => [
        // 'mobile'
    ],

    /*
     |--------------------------------------------------------------------------
     | except transform fields ( POST | GET ) from arabic to eastern
     |--------------------------------------------------------------------------
     |
     | all none string value will be ignore by default, you can ignore fields by name (key) of POST or GET
     |
     */
    'except_from_arabic_to_eastern' => [
        // 'mobile'
    ]
];

Change log

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

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email yemenifree@yandex.com instead of using the issue tracker.

Credits

License

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

yemenifree/laravel-arabic-numbers-middleware 适用场景与选型建议

yemenifree/laravel-arabic-numbers-middleware 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 135.75k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2017 年 10 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「numbers」 「middleware」 「laravel」 「arabic」 「yemenifree」 「laravel-arabic-numbers-middleware」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 yemenifree/laravel-arabic-numbers-middleware 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 yemenifree/laravel-arabic-numbers-middleware 我们能提供哪些服务?
定制开发 / 二次开发

基于 yemenifree/laravel-arabic-numbers-middleware 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 135.75k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 3
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-04