zvermafia/transliteration-laravel
Composer 安装命令:
composer require zvermafia/transliteration-laravel
包简介
Integration of the zvermafia/transliteration with Laravel
README 文档
README
Integration of the zvermafia/transliteration with Laravel.
Navigation by sections
Install
Via Composer
$ composer require zvermafia/transliteration-laravel
Setup
There are two options for your choice, alif and lotin. With the option alif will be used the alif.uz's API. And with the option lotin will be used the lotin.uz's API.
Default option is alif. But if you want to change this to the lotin option then you simply need to add a TRANSLITERATOR key with the value lotin into the .env file.
TRANSLITERATOR=lotin
But if you want to extend this package with your own realization then you need to publish package's configuration file and update it with your option.
To publish the configuration file simply execute the php artisan vendor:publish command in the project root folder and select the Zvermafia\TransliterationLaravel\TransliteratorServiceProvider as a provider.
Usage
You can use a LaraTransliterator facade but I'll show you another way in the example below.
Let's assume we have a PoorWorkerController with a translit method in which we want transliterate a requested text (with POST method) and return the result as JSON.
<?php namespace App\Http\Controllers; // use LaraTransliterator; // but we won't use the facade in this example use Zvermafia\Transliteration\Interfaces\TransliteratorInterface; class PoorWorkerController { public function translit(Request $request, TransliteratorInterface $transliterator) { $result = $transliterator->setText($request->input('text')) ->toCyrillic() ->translit() ->getResult(); return response()->json(compact('result')); } }
For AJAX requests you can use a ready-made controller! Firstly you must define a route for the controller:
// in your routes file Route::post('translit', '\Zvermafia\TransliterationLaravel\Controllers\TransliteratorController');
For AJAX request demonstration we'll use jQuery library:
$.ajax({ url: '/translit', type: 'POST', data: { // _token: $('meta[name="csrf-token"]').attr('content'), text: 'Salom, dunyo!', to_cyrillic: 1 }, dataType: 'JSON' }) .done(function (response) { if (response.code === 200) { alert(response.result); } else { alert('Something went wrong... Check the console for logs, please.'); console.log(response); } }) .fail(function (response) { console.log('Whoops, something went wrong... Check the response below:'); console.log(response); });
// A response will be like below: { "code": 200, "text": "Salom, dunyo!", "to_cyrillic": 1, "result": "Салом, дунё!" } // Or if an error occurs the response code will be different from 200 // and response will be like below: { "code": 200, "message": "Transliterated text", }
Change log
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email mohirjon@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
zvermafia/transliteration-laravel 适用场景与选型建议
zvermafia/transliteration-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「api」 「library」 「transliteration」 「laravel」 「transliterator」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zvermafia/transliteration-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zvermafia/transliteration-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zvermafia/transliteration-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Inbox pattern process implementation for your Laravel Applications
Simple ASCII output of array data
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-21