• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

overtrue/laravel-pinyin: Chinese to Pinyin translator for Laravel 5 / Lumen

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

overtrue/laravel-pinyin

开源软件地址(OpenSource Url):

https://github.com/overtrue/laravel-pinyin

开源编程语言(OpenSource Language):

PHP 100.0%

开源软件介绍(OpenSource Introduction):

Laravel-Pinyin

Chinese to Pinyin translator for Laravel5 / Lumen based on overtrue/pinyin.

Latest Stable Version Total Downloads Latest Unstable Version License

Sponsor me

Install

composer require "overtrue/laravel-pinyin:~4.0"

For Laravel

(If you are using Laravel >= 5.5, the auto-discovery feature will handle these two steps for you.)

Add the following line to the section providers of config/app.php:

'providers' => [
    //...
    Overtrue\LaravelPinyin\ServiceProvider::class,
],

as optional, you can use facade:

'aliases' => [
    //...
    'Pinyin' => Overtrue\LaravelPinyin\Facades\Pinyin::class,
],

For Lumen

Add the following line to bootstrap/app.php after // $app->withEloquent();

...
// $app->withEloquent();

$app->register(Overtrue\LaravelPinyin\ServiceProvider::class);
...

Usage

you can get the instance of Overtrue\Pinyin\Pinyin from app container:

$pinyin = app('pinyin');
echo $pinyin->sentence('带着希望去旅行,比到达终点更美好');
// dài zhe xī wàng qù lǔ xíng, bǐ dào dá zhōng diǎn gèng měi hǎo

There are more convenient functions:

function method
pinyin() app('pinyin')->convert()
pinyin_abbr() app('pinyin')->abbr()
pinyin_permalink app('pinyin')->permalink()
pinyin_sentence app('pinyin')->sentence()
var_dump(pinyin('带着希望去旅行,比到达终点更美好'));
// ["dai", "zhe", "xi", "wang", "qu", "lv", "xing", "bi", "dao", "da", "zhong", "dian", "geng", "mei", "hao"]

var_dump(pinyin_abbr('带着希望去旅行'));
// dzxwqlx
...

Using facade:

use Pinyin; // Facade class, NOT Overtrue\Pinyin\Pinyin

var_dump(Pinyin::convert('带着希望去旅行'));
// ["dai", "zhe", "xi", "wang", "qu", "lv", "xing"]

echo Pinyin::sentence('带着希望去旅行,比到达终点更美好');
// dài zhe xī wàng qù lǔ xíng, bǐ dào dá zhōng diǎn gèng měi hǎo

About overtrue/pinyin specific configuration and use, refer to: overtrue/pinyin

❤️ Sponsor me

Sponsor me

如果你喜欢我的项目并想支持它,点击这里 ❤️

Project supported by JetBrains

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》

License

MIT




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap