Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

🇨🇳 Chinese to Pinyin translator for Laravel 5 / Lumen

License

NotificationsYou must be signed in to change notification settings

overtrue/laravel-pinyin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chinese to Pinyin translator for Laravel5 / Lumen based onovertrue/pinyin.

Latest Stable VersionTotal DownloadsLatest Unstable VersionLicense

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 sectionproviders ofconfig/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 tobootstrap/app.php after// $app->withEloquent();

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

Usage

you can get the instance ofOvertrue\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:

functionmethod
pinyin()app('pinyin')->convert()
pinyin_abbr()app('pinyin')->abbr()
pinyin_permalinkapp('pinyin')->permalink()
pinyin_sentenceapp('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:

usePinyin;// Facade class, NOT Overtrue\Pinyin\Pinyinvar_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

Aboutovertrue/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

About

🇨🇳 Chinese to Pinyin translator for Laravel 5 / Lumen

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp