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

Abandoned → [https://github.com/alphasnow/opencc-php](/?search=https%3A%2F%2Fgithub.com%2Falphasnow%2Fopencc-php)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

sleep-cat/opencc-php
====================

OpenCC made with PHP

v3.3.3(5y ago)96665[1 issues](https://github.com/alphasnow/opencc-php/issues)MITPHPPHP &gt;=7.0

Since Aug 12Pushed 4y ago1 watchersCompare

[ Source](https://github.com/alphasnow/opencc-php)[ Packagist](https://packagist.org/packages/sleep-cat/opencc-php)[ Docs](https://github.com/alphasnow/opencc)[ RSS](/packages/sleep-cat-opencc-php/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (7)Versions (21)Used By (0)

opencc-php
==========

[](#opencc-php)

介绍
--

[](#介绍)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ab1c5b21db4881e30047e43238c257f070550868ced87ab8a88be2b1c940b038/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c706861736e6f772f6f70656e63632d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alphasnow/opencc-php)[![Total Downloads](https://camo.githubusercontent.com/8b16ff9c431d9aea49ea5c893b9497136559e36e19954b41fb8ce8ab40a2e17d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c706861736e6f772f6f70656e63632d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alphasnow/opencc-php)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

中文简繁转换开源项目，支持词汇级别的转换、异体字转换和地区习惯用词转换（中国大陆、臺湾、香港）。

安装
--

[](#安装)

1. 第一步,在服务器安装`opencc`

    - Ubuntu `apt install opencc`
    - CentOS `yum install opencc opencc-tools`
    - Window x32 [下载](https://ci.appveyor.com/api/projects/Carbo/opencc/artifacts/OpenCC.zip?branch=master&job=Environment:%20nodejs_version=none;%20Platform:%20x86)
    - Window x64 [下载](https://ci.appveyor.com/api/projects/Carbo/opencc/artifacts/OpenCC.zip?branch=master&job=Environment:%20nodejs_version=none;%20Platform:%20x64)

    >
2. 第二步,使用`Composer`安装`opencc-php`

    ```
    composer require alphasnow/opencc-php
    ```

应用配置
----

[](#应用配置)

### Laravel应用

[](#laravel应用)

1. (Laravel5.5+ 忽略)在 `config/app.php` 注册 ServiceProvider 和 Facade

    ```
    [
        'providers' => [
            // ...
            AlphaSnow\OpenCC\ServiceProvider::class,
        ],
        'aliases' => [
            // ...
            'OpenCC' => AlphaSnow\OpenCC\Facade::class,
        ]
    ];
    ```
2. 发布配置文件

    ```
    php artisan vendor:publish --provider="AlphaSnow\OpenCC\ServiceProvider"
    ```
3. 修改配置文件 `config/opencc.php`

    ```
    return [
        // 执行文件的路径,默认:/usr/bin/opencc
        'binary_path'=> env('OPENCC_BINARY', '/usr/bin/opencc'),
        // 预设配置文件夹的路径,默认:/usr/share/opencc
        'config_path'=> env('OPENCC_CONFIG', '/usr/share/opencc'),
    ];
    ```

    或修改环境配置 `.env`

    ```
    OPENCC_BINARY=/usr/bin/opencc
    OPENCC_CONFIG=/usr/share/opencc

    ```

快速使用
----

[](#快速使用)

### Laravel应用

[](#laravel应用-1)

```
// laravel应用可用外观
// 参数1:待转换内容, 参数2:预设配置(可省略.json)
$simplified = \OpenCC::convert('天氣乍涼人寂寞，光陰須得酒消磨。且來花裏聽笙歌。','t2s.json');
print_r($simplified);
// 天气乍凉人寂寞，光阴须得酒消磨。且来花里听笙歌。

$traditional = \OpenCC::convert('四面垂杨十里荷。问云何处最花多。画楼南畔夕阳和。', 's2t');
print_r($traditional);
// 四面垂楊十里荷。問云何處最花多。畫樓南畔夕陽和。
```

### 其他应用

[](#其他应用)

```
use AlphaSnow\OpenCC\Command;
use AlphaSnow\OpenCC\OpenCC;

$command = new Command('/usr/bin/opencc','/usr/share/opencc');
$openCC = new OpenCC($command);

$result = $openCC->convert('天氣乍涼人寂寞，光陰須得酒消磨。且來花裏聽笙歌。','t2s.json');
print_r($result);
// 天气乍凉人寂寞，光阴须得酒消磨。且来花里听笙歌。
```

预设配置
----

[](#预设配置)

- s2t.json Simplified Chinese to Traditional Chinese 简体到繁体
- t2s.json Traditional Chinese to Simplified Chinese 繁体到简体

备注说明
----

[](#备注说明)

- 如需PHP原生扩展, 可使用 [opencc4php](https://github.com/nauxliu/opencc4php).
- Window系统`opencc`配置示例 ```
    OPENCC_BINARY=D:/OpenCC/build/bin/opencc.exe
    OPENCC_BINARY=D:/OpenCC/build/share/opencc

    ```

License
-------

[](#license)

See [LICENSE](LICENSE).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 97.3% 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 ~31 days

Recently: every ~131 days

Total

20

Last Release

1872d ago

Major Versions

v1.0.3 → v3.0.02019-10-23

PHP version history (4 changes)v1.0.0PHP ^7.0

v3.1.0PHP ^7.1.3

v3.2.0PHP ^7.2

v3.3.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/90877a466dd664c9a6b4ccd2a9ccf46e54427307198fa11201976aac968f5fca?d=identicon)[alphasnow](/maintainers/alphasnow)

---

Top Contributors

[![alphasnow](https://avatars.githubusercontent.com/u/8286647?v=4)](https://github.com/alphasnow "alphasnow (36 commits)")[![andersonfantw](https://avatars.githubusercontent.com/u/47234075?v=4)](https://github.com/andersonfantw "andersonfantw (1 commits)")

---

Tags

laravelopenccopencc-phptraditional-chinese-charactersphplaravelOpenCC

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[amranidev/laracombee

Recommendation system for laravel

11636.7k1](/packages/amranidev-laracombee)[arnolem/tailwindphp

TailwindPHP - use Tailwind CSS in your PHP projects (without npm)

131.1k](/packages/arnolem-tailwindphp)[wujunze/money-wrapper

MoneyPHP Wrapper

113.8k](/packages/wujunze-money-wrapper)

PHPackages © 2026

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