PHPackages                             sinacms/pinyin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sinacms/pinyin

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sinacms/pinyin
==============

Chinese to pinyin translator.

2.6.7(10y ago)3131MITPHP

Since Jul 16Pushed 8y ago1 watchersCompare

[ Source](https://github.com/sinacms/pinyin)[ Packagist](https://packagist.org/packages/sinacms/pinyin)[ Docs](https://github.com/overtrue/pinyin)[ RSS](/packages/sinacms-pinyin/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (26)Used By (0)

Pinyin
======

[](#pinyin)

[![Build Status](https://camo.githubusercontent.com/e868b4f9dde2482f5d56729f487dceffc02487d44bc58cd221bdc2394da06486/68747470733a2f2f7472617669732d63692e6f72672f6f766572747275652f70696e79696e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/overtrue/pinyin)[![Latest Stable Version](https://camo.githubusercontent.com/10cbf8c470851ad0bebd058635ad6a781608dfc585994e7837e6578735bf8bb0/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f70696e79696e2f762f737461626c652e737667)](https://packagist.org/packages/overtrue/pinyin) [![Total Downloads](https://camo.githubusercontent.com/7a1ba91c5227ad10249bc6b1c7ca4d01a91e4151b8c6148e02594049132fe200/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f70696e79696e2f646f776e6c6f6164732e737667)](https://packagist.org/packages/overtrue/pinyin) [![Latest Unstable Version](https://camo.githubusercontent.com/33da35dba8b7f80211bb8dec99ae1d4feec1dc089a0c2f653dcad00c58f49c1a/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f70696e79696e2f762f756e737461626c652e737667)](https://packagist.org/packages/overtrue/pinyin) [![License](https://camo.githubusercontent.com/b66704519178e7ac6e1749812b75fcb59d56d65e2510f866b968d8a27ce23846/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f70696e79696e2f6c6963656e73652e737667)](https://packagist.org/packages/overtrue/pinyin)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f787f804d17068ed0c89625b419266d63ddad6ef77aefa5391e0719fa80e702b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f766572747275652f70696e79696e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/overtrue/pinyin/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/100caeca7a948ca9153444f23f978c46d431185e4350b0e93674ffddcaf91c39/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f766572747275652f70696e79696e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/overtrue/pinyin/?branch=master)

基于 [CC-CEDICT](http://cc-cedict.org/wiki/) 词典的中文转拼音工具，更准确的汉字转拼音解决方案。

SAE服务地址：

```
use Overtrue\Pinyin\Pinyin;

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

//多音字
// 了
Pinyin::trans('了然'); // liǎo rán
Pinyin::trans('来了'); // lái le

// 还
Pinyin::trans('还有'); // hái yǒu
Pinyin::trans('交还'); // jiāo huán

// 什
Pinyin::trans('什么'); // shén me
Pinyin::trans('什锦'); // shí jǐn

// 便
Pinyin::trans('便当'); // biàn dāng
Pinyin::trans('便宜'); // pián yí

// 剥
Pinyin::trans('剥皮'); // bāo pí
Pinyin::trans('剥皮器'); // bō pí qì

// 不
Pinyin::trans('赔不是'); // péi bú shi
Pinyin::trans('跑了和尚，跑不了庙'); // pǎo le hé shàng , pǎo bù liǎo miào

// 降
Pinyin::trans('降温'); // jiàng wēn
Pinyin::trans('投降'); // tóu xiáng

// 都
Pinyin::trans('首都'); // shǒu dū
Pinyin::trans('都什么年代了'); // dōu shén me nián dài le

// 乐
Pinyin::trans('快乐'); // kuài lè
Pinyin::trans('音乐'); // yīn yuè

// 长
Pinyin::trans('成长'); // chéng zhǎng
Pinyin::trans('长江'); // cháng jiāng

// 难
Pinyin::trans('难民'); // nàn mín
Pinyin::trans('难过'); // nán guò
...
```

安装
--

[](#安装)

1. 使用 Composer 安装:

    ```
    composer require overtrue/pinyin:2.*

    ```

    或者在你的项目 composer.json 加入：

    ```
    {
        "require": {
            "overtrue/pinyin": "2.*"
        }
    }
    ```
2. 直接下载文件 `src/Pinyin/Pinyin.php` 引入到项目中。

使用
--

[](#使用)

```
