PHPackages                             ysp/php-opencc - 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. ysp/php-opencc

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

ysp/php-opencc
==============

中文简繁转换，支持词汇级别的转换、异体字转换和地区习惯用词转换（中国大陆、台湾、香港、日本新字体）。基于 \[BYVoid/OpenCC\](https://github.com/BYVoid/OpenCC) 数据实现。

v1.0.2(2y ago)1135MITPHPPHP &gt;=7.1

Since Mar 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/askme-gpt/php-opencc)[ Packagist](https://packagist.org/packages/ysp/php-opencc)[ GitHub Sponsors](https://github.com/overtrue)[ RSS](/packages/ysp-php-opencc/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

来源
==

[](#来源)

这个包来源于： ，为啥要做同个功能的轮子呢？因为这个包不支持php8以前的版本，我有些老项目，升级比较麻烦，因此把代码稍微改了一下，以便php7.1以后的版本都能用。 如果你的php版本在php8以上，请使用  ，以便获取最新的更新，虽然我的这个包也能在php8的环境下跑，但是性能肯定没有官方的那么好，因为jit原因。

这个版本阉割了命令行功能，因为有些命令行有些单独的依赖，那些依赖也使用了php8，因此去掉了。

如果遇到不兼容的问题，直接提issue，我会尽量在24小时之内处理完毕。

PHP OpenCC
==========

[](#php-opencc)

中文简繁转换，支持词汇级别的转换、异体字转换和地区习惯用词转换（中国大陆、台湾、香港、日本新字体）。基于 [BYVoid/OpenCC](https://github.com/BYVoid/OpenCC) 数据实现。

[![Build Status](https://github.com/ysp/php-opencc/actions/workflows/test.yml/badge.svg)](https://github.com/ysp/php-opencc/actions/workflows/test.yml)[![Latest Stable Version](https://camo.githubusercontent.com/3821ff4e9e5d72c2c5e4e3c389477f4de87aa50352bb2310cff15f0b26512605/68747470733a2f2f706f7365722e707567782e6f72672f7973702f7068702d6f70656e63632f762f737461626c65)](https://packagist.org/packages/ysp/php-opencc)[![Total Downloads](https://camo.githubusercontent.com/0200f5cbbea0438786ba513446e4200ca23a90f0fc88825a2a48d506f77b9204/68747470733a2f2f706f7365722e707567782e6f72672f7973702f7068702d6f70656e63632f646f776e6c6f616473)](https://packagist.org/packages/ysp/php-opencc)[![License](https://camo.githubusercontent.com/3206bc2fa0e0f60cbc7953393592c24a04e68e02ff2c43e5b2f65d9f528e3958/68747470733a2f2f706f7365722e707567782e6f72672f7973702f7068702d6f70656e63632f6c6963656e7365)](https://packagist.org/packages/ysp/php-opencc)

安装
--

[](#安装)

```
composer require ysp/php-opencc -vvv
```

使用
--

[](#使用)

```
use Ysp\OpenCC\OpenCC;

echo OpenCC::convert('服务器', 'SIMPLIFIED_TO_TAIWAN_WITH_PHRASE');
// output: 伺服器
```

### 使用策略别名

[](#使用策略别名)

```
use Ysp\OpenCC\OpenCC;
use Ysp\OpenCC\Strategy;

// 以下方法等价：

// 方法
echo OpenCC::s2tw('服务器');
echo OpenCC::simplifiedToTaiwan('服务器');

// 字符串
echo OpenCC::convert('服务器', 's2tw');
echo OpenCC::convert('服务器', 'S2TW');
echo OpenCC::convert('服务器', 'SIMPLIFIED_TO_TAIWAN');

// 常量
echo OpenCC::convert('服务器', Strategy::S2TW);
echo OpenCC::convert('服务器', Strategy::SIMPLIFIED_TO_TAIWAN);
```

### 转换策略

[](#转换策略)

策略 （别名）说明`SIMPLIFIED_TO_TRADITIONAL(S2T)`简体到繁体`SIMPLIFIED_TO_HONGKONG(S2HK)`简体到香港繁体`SIMPLIFIED_TO_JAPANESE(S2JP)`简体到日文`SIMPLIFIED_TO_TAIWAN(S2TW)`简体到台湾正体`SIMPLIFIED_TO_TAIWAN_WITH_PHRASE(2TWP)`简体到台湾正体, 带词汇本地化`HONGKONG_TO_TRADITIONAL(HK2T)`香港繁体到正体`HONGKONG_TO_SIMPLIFIED(HK2S)`香港繁体到简体`TAIWAN_TO_SIMPLIFIED(TW2S)`台湾正体到简体`TAIWAN_TO_TRADITIONAL(TW2T)`台湾正体到繁体`TAIWAN_TO_SIMPLIFIED_WITH_PHRASE(TW2SP)`台湾正体到简体, 带词汇本地化`TRADITIONAL_TO_HONGKONG(T2HK)`正体到香港繁体`TRADITIONAL_TO_SIMPLIFIED(T2S)`繁体到简体`TRADITIONAL_TO_TAIWAN(T2TW)`繁体到台湾正体`TRADITIONAL_TO_JAPANESE(T2JP)`繁体到日文`JAPANESE_TO_TRADITIONAL(JP2T)`日文到繁体`JAPANESE_TO_SIMPLIFIED(JP2S)`日文到简体License
-------

[](#license)

MIT

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

825d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b35a2dc6ed6d92d594dc02835a590ff053a1c39448f33c53c9c37a8fe08dc11?d=identicon)[ShuiPingYang](/maintainers/ShuiPingYang)

---

Top Contributors

[![dbx192](https://avatars.githubusercontent.com/u/131589877?v=4)](https://github.com/dbx192 "dbx192 (3 commits)")

### Embed Badge

![Health badge](/badges/ysp-php-opencc/health.svg)

```
[![Health](https://phpackages.com/badges/ysp-php-opencc/health.svg)](https://phpackages.com/packages/ysp-php-opencc)
```

###  Alternatives

[abhi1693/yii2-config

Yii2 manage configuration from database

1311.1k1](/packages/abhi1693-yii2-config)[phpmentors/stagehand-fsm

A finite state machine

361.1k](/packages/phpmentors-stagehand-fsm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
