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

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

reidier/php-opencc
==================

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

1.0.1(2y ago)054MITPHPPHP &gt;=7.2

Since Sep 7Pushed 2y agoCompare

[ Source](https://github.com/ReidieR/php-opencc)[ Packagist](https://packagist.org/packages/reidier/php-opencc)[ GitHub Sponsors](https://github.com/overtrue)[ RSS](/packages/reidier-php-opencc/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (3)Used By (0)

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

[](#php-opencc)

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

[![Build Status](https://github.com/overtrue/php-opencc/actions/workflows/test.yml/badge.svg)](https://github.com/overtrue/php-opencc/actions/workflows/test.yml)[![Latest Stable Version](https://camo.githubusercontent.com/dbd8640b28b7be1c993d5d7ad7ab5115f3ace939acc4ca7eaea96f41d201caac/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f7068702d6f70656e63632f762f737461626c65)](https://packagist.org/packages/overtrue/php-opencc)[![Total Downloads](https://camo.githubusercontent.com/b2ffee9a9587b2539e720159cfae9611e23ff51bffcac712e6b5571cd194ba43/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f7068702d6f70656e63632f646f776e6c6f616473)](https://packagist.org/packages/overtrue/php-opencc)[![License](https://camo.githubusercontent.com/c3d32a7a68112e7cf7a7b46ad99986d5c1b26e0f6b6fb491017cfddae1a67946/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f7068702d6f70656e63632f6c6963656e7365)](https://packagist.org/packages/overtrue/php-opencc)

安装
--

[](#安装)

```
$ composer require overtrue/php-opencc -vvv
```

使用
--

[](#使用)

```
use Overtrue\PHPOpenCC\OpenCC;

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

### 使用策略别名

[](#使用策略别名)

```
use Overtrue\PHPOpenCC\OpenCC;
use Overtrue\PHPOpenCC\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)`日文到简体### 在命令行使用

[](#在命令行使用)

```
$ php vendor/bin/opencc "汉字" s2tw
```

说明：

```
$ php vendor/bin/opencc --help
Description:
  中文简繁转换，支持词汇级别的转换、异体字转换和地区习惯用词转换（中国大陆、台湾、香港、日本新字体）。

Usage:
  convert  []

Arguments:
  string                待转换的字符串
  strategy              转换策略 [default: "SIMPLIFIED_TO_TRADITIONAL"]
```

❤️ 赞助我
------

[](#heart-赞助我)

如果你喜欢我的项目并想支持它，[点击这里 ❤️](https://github.com/sponsors/overtrue)

Project supported by JetBrains
------------------------------

[](#project-supported-by-jetbrains)

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.

[![](https://camo.githubusercontent.com/3cf726e7cdadba47755b7f7ea4227945a92a2fa48aadf4a2573140ec6501c989/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f73746f726167652f70726f64756374732f636f6d70616e792f6272616e642f6c6f676f732f6a625f6265616d2e737667)](https://www.jetbrains.com/?from=https://github.com/overtrue)

参与贡献
----

[](#参与贡献)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/overtrue/php-opencc/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/overtrue/php-opencc/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

License
-------

[](#license)

MIT

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 66.7% 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

Every ~0 days

Total

2

Last Release

985d ago

PHP version history (2 changes)1.0.0PHP 7.2

1.0.1PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce7222d31c41f69a7f971b33a0b15212f8c98929ba4da2d844185cbd06975fb9?d=identicon)[reidier](/maintainers/reidier)

---

Top Contributors

[![overtrue](https://avatars.githubusercontent.com/u/1472352?v=4)](https://github.com/overtrue "overtrue (6 commits)")[![ReidieR](https://avatars.githubusercontent.com/u/56117443?v=4)](https://github.com/ReidieR "ReidieR (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M568](/packages/symfony-maker-bundle)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[shivas/versioning-bundle

Symfony application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations

1121.2M1](/packages/shivas-versioning-bundle)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[overtrue/php-opencc

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

12130.7k](/packages/overtrue-php-opencc)

PHPackages © 2026

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