{"id":37005465,"url":"https://github.com/chineseboost/php-pinyin","last_synced_at":"2026-01-14T00:40:25.270Z","repository":{"id":46309723,"uuid":"231220184","full_name":"chineseboost/php-pinyin","owner":"chineseboost","description":"Pinyin and hanzi tools in pure PHP | 纯PHP的汉语拼音和汉字工具","archived":false,"fork":false,"pushed_at":"2021-10-31T16:24:14.000Z","size":4299,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-17T23:44:07.902Z","etag":null,"topics":["hacktoberfest","hacktoberfest2020","hacktoberfest2021","hacktoberfest2022","hanzi","php","pinyin"],"latest_commit_sha":null,"homepage":"https://www.chineseboost.com/tools/hanzi-pinyin-conversion","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chineseboost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-01T13:30:00.000Z","updated_at":"2024-11-26T13:02:56.000Z","dependencies_parsed_at":"2022-08-29T20:21:20.263Z","dependency_job_id":null,"html_url":"https://github.com/chineseboost/php-pinyin","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/chineseboost/php-pinyin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chineseboost%2Fphp-pinyin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chineseboost%2Fphp-pinyin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chineseboost%2Fphp-pinyin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chineseboost%2Fphp-pinyin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chineseboost","download_url":"https://codeload.github.com/chineseboost/php-pinyin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chineseboost%2Fphp-pinyin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","hacktoberfest2020","hacktoberfest2021","hacktoberfest2022","hanzi","php","pinyin"],"created_at":"2026-01-14T00:40:25.102Z","updated_at":"2026-01-14T00:40:25.249Z","avatar_url":"https://github.com/chineseboost.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Pinyin\n\n[![BuildStatus](https://travis-ci.org/chineseboost/php-pinyin.svg?branch=master)](https://travis-ci.org/chineseboost/php-pinyin)\n[![Coverage Status](https://coveralls.io/repos/github/chineseboost/php-pinyin/badge.svg?branch=master)](https://coveralls.io/github/chineseboost/php-pinyin?branch=master)\n[![StyleCI](https://github.styleci.io/repos/231220184/shield?branch=master)](https://github.styleci.io/repos/231220184)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nPinyin and hanzi tools in pure PHP | 纯PHP的汉语拼音和汉字工具\n\nYou can try a web version of this here: [https://www.chineseboost.com/tools/hanzi-pinyin-conversion](https://www.chineseboost.com/tools/hanzi-pinyin-conversion)\n\n## Usage\n\nInstall via composer:\n\n```bash\ncomposer require chineseboost/php-pinyin\n```\n\n### Converting hanzi into pinyin\n\nYou can convert hanzi strings into pinyin with a furthest-forward matching\nstrategy.\n\nphp-pinyin handles a lot of cases that other pinyin generation tools do not,\nincluding many 多音字, 儿化 and common mis-parsings.\n\n```php\n\u003c?php\n\nuse Pinyin\\Hanzi\\HanziSentence;\n\n(new HanziSentence('科学家的工作就是对理论加以检验。'))-\u003easPinyin()-\u003etoneMarked();\n// \"Kēxuéjiā de gōngzuò jiùshì duì lǐlùn jiāyǐ jiǎnyàn.\"\n\n(new HanziSentence('他下了车，扑哧扑哧地穿过泥地去开门。'))-\u003easPinyin()-\u003etoneMarked();\n// \"Tā xià le chē, pū chī pū chī de chuānguò ní dì qù kāimén.\"\n\n(new HanziSentence('我兒子真的是一點兒生活常識都沒有！'))-\u003easPinyin()-\u003etoneMarked();\n// \"Wǒ érzi zhēn de shì yīdiǎnr shēnghuó chángshí dōu méiyǒu!\"\n\n(new HanziSentence('食品供给'))-\u003easPinyin()-\u003etoneMarked();\n// \"Shípǐn gōngjǐ\"\n\n(new HanziSentence('政府将在2015年对旅游行业加以规范。'))-\u003easPinyin()-\u003etoneMarked();\n// \"Zhèngfǔ jiāng zài èr líng yī wǔ nián duì lǚyóu hángyè jiāyǐ guīfàn.\"\n\n(new HanziSentence('我已经累得不得了了。'))-\u003easPinyin()-\u003etoneMarked();\n// \"Wǒ yǐjīng lèi de bùdéliǎo le.\"\n\n```\n\n### Working with pinyin\n\nYou can also work directly with pinyin strings, for example to convert from\ntone numbers to tone marks.\n\nIt does not matter if the source string has a mix of tone numbers and tone\nmarks, so this can also be used to normalise a pinyin string.\n\n```php\n\u003c?php\n\nuse Pinyin\\PinyinSentence;\n\n$sentence = new PinyinSentence('Ta1 zen3me hai2 mei2 xia4lai2 ne?');\n$sentence-\u003etoneMarked();\n// \"Tā zěnme hái méi xiàlái ne?\"\n\n$sentence = new PinyinSentence(\n    'Cong2 bāshi2 lóu ke3yǐ kan4 dào zheng3gè cheng2shì, zan2men0 shang4qù kan4 yīxia4 ba5.'\n);\n$sentence-\u003etoneMarked();\n// \"Cóng bāshí lóu kěyǐ kàn dào zhěnggè chéngshì, zánmen shàngqù kàn yīxià ba.\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchineseboost%2Fphp-pinyin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchineseboost%2Fphp-pinyin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchineseboost%2Fphp-pinyin/lists"}