Download the PHP package overtrue/pinyin without Composer

On this page you can find all versions of the php package overtrue/pinyin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pinyin

Pinyin

Test Latest Stable Version Total Downloads Latest Unstable Version License

:cn: 基于 mozillazg/pinyin-data 词典的中文转拼音工具,更准确的支持多音字的汉字转拼音解决方案。

喜欢我的项目?点击这里支持我

安装

使用 Composer 安装:

使用

拼音风格

除了获取首字母的方法外,所有方法都支持第二个参数,用于指定拼音的格式,可选值为:

返回值

除了 permalink 返回字符串外,其它方法都返回集合类型 Overtrue\Pinyin\Collection

你可以通过以下方式访问集合内容:

文字段落转拼音

生成用于链接的拼音字符串

通常用于文章链接等,可以使用 permalink 方法获取拼音字符串:

获取首字符字符串

通常用于创建搜索用的索引,可以使用 abbr 方法转换:

姓名首字母

将首字作为姓氏转换,其余作为普通词语转换:

姓名转换

姓名的姓的读音有些与普通字不一样,比如 ‘单’ 常见的音为 dan,而作为姓的时候读 shan

护照姓名转换

根据国家规定 关于中国护照旅行证上姓名拼音 ü(吕、律、闾、绿、女等)统一拼写为 YU 的提醒 的规则,将 ü 转换为 yu

多音字

多音字的返回值为关联数组的集合,默认返回去重后的所有读音:

如果不想要去重,可以数组形式返回:

单字转拼音

和多音字类似,单字的返回值为字符串,多音字将根据该字字频调整得到常用音:

Warning

当单字处理时由于多音字来自词频表中取得常用音,所以在词语环境下可能出现不正确的情况,建议使用多音字处理。

更多使用请参考 测试用例

v/yu/ü 的问题

根据国家语言文字工作委员会的规定,lvlyu 都是正确的,但是 lv 是最常用的,所以默认使用 lv,如果你需要使用其他的,可以在初始化时传入:

Warning

仅在拼音风格为非 none 模式下有效。

命令行工具

你可以使用命令行来实现拼音的转换:

更多使用方法,可以查看帮助文档:

在 Laravel 中使用

独立的包在这里:overtrue/laravel-pinyin

中文简繁转换

如何你有这个需求,也可以了解我的另一个包:overtrue/php-opencc

Contribution

欢迎提意见及完善补充词库:

参考

:heart: Sponsor me

Sponsor me

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

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


All versions of pinyin with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package overtrue/pinyin contains the following files

Loading the files please wait ....