PHPackages                             youaoi/php-mecab - 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. youaoi/php-mecab

ActiveLibrary

youaoi/php-mecab
================

mecab reading for php7

1.0.0(7y ago)938.5k↓27.9%2MITPHPPHP &gt;=7.0.0

Since Feb 4Pushed 7y ago1 watchersCompare

[ Source](https://github.com/youaoi/php-mecab)[ Packagist](https://packagist.org/packages/youaoi/php-mecab)[ Docs](https://github.com/youaoi/php-mecab)[ RSS](/packages/youaoi-php-mecab/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

MeCab reading php7 library
==========================

[](#mecab-reading-php7-library)

オープンソース 形態素解析エンジン [MeCab](http://taku910.github.io/mecab/) を、PHP用のインストール不要なライブラリ化した [ateliee/mecab](https://github.com/ateliee/mecab) を更に使いやすくしました。

また、Laravelなどで組み込みやすいように調整を加えてあります。

使い方
---

[](#使い方)

事前にMeCabをConsoleで使えるようにしてください。

また、使用する [辞書](https://github.com/neologd/mecab-ipadic-neologd) によって解析結果が変わる可能性があります。

###### composer.json

[](#composerjson)

```
    "require": {
        "youaoi/php-mecab": "dev-master"
    },

```

###### php

[](#php)

```
use Youaoi\MeCab\MeCab;
...

// 設定 ※任意。不要な値は省略できます。

    MeCab::setDefaults([

        // PATHが通っていないmecabを起動させる時に設定(default: mecab)
        'command' => '~/.local/bin/mecab',

        // 独自の辞書ディレクトリを利用する場合に設定(default: null)
        'dictionaryDir' => '~/.local/mecab-neologd',

        // 指定辞書を利用し解析。複数利用時はカンマ区切り(default: null)
        'dictionary' => 'hoge1.dic,hoge2.dic',

        // 解析時に生成するMeCabWordのclass名を指定(default: Youaoi\\MeCab\\MeCabWord)
        'wordClass' => User\\MeCab\\MeCabWord::class,
    ]);

...
// シンプルな使い方１

    echo MeCab::toReading('すもももももももものうち');
    // Output: スモモモモモモモモノウチ

    echo MeCab::toReading('山田太郎');
    // Output: ヤマダタロウ

    echo MeCab::toReading('C-3PO');
    // Output:

    echo MeCab::toReading('出席番号:13番');
    // Output: シュッセキバンゴウバン

// シンプルな使い方２

    echo MeCab::toSortText('すもももももももものうち');
    // Output: スモモモモモモモモノウチ

    echo MeCab::toSortText('山田太郎');
    // Output: ヤマダタロウ

    echo MeCab::toSortText('C-3PO');
    // Output: C-3PO

    echo MeCab::toSortText('出席番号:13番');
    // Output: シュッセキバンゴウ:13バン

// ソート用文字列の作成方法
    $sentence = '仕様書_copy-new(3)';

    $text = MeCab::toSortText($sentence);
    $text = strtoupper(mb_convert_kana($text, 'rnashk'));

    // 漢字範囲など精度が悪いが、精密に判定する必要が無いので、ざっくりと削除
    $text = preg_replace('/[^ｦ-ﾝA-Z0-9一-龠]+/u','' ,$text);

    echo $text;
    // Output: ｼﾖｳｼｮCOPYNEW3

...

// データを解析する

    var_dump($a = MeCab::parse('すもももももももものうち'));

    $mecab = new MeCab();

    var_dump($b = $mecab->analysis('すもももももももものうち'));

    // $a == $b

```

※使用する環境によって、解析結果が変わり、テストケースが通らなくなる場合があります。

想定する活用環境
--------

[](#想定する活用環境)

UNIX系サーバーにて動作確認。特に制約の多いレンタルサーバーで利用する事を前提として開発。

作者は下記環境にて利用中

- [レンタルサーバーサービス「XREA（エクスリア）」](https://www.xrea.com/)
- [レンタルサーバー CORESERVER（コアサーバー）](https://www.coreserver.jp/)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

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

2661d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d15628db5f68395bc9c6cc976b225bf3cb87e11f34e8c41b314c546d90c3d43?d=identicon)[youaoi](/maintainers/youaoi)

---

Top Contributors

[![youaoi](https://avatars.githubusercontent.com/u/5134083?v=4)](https://github.com/youaoi "youaoi (15 commits)")[![ateliee](https://avatars.githubusercontent.com/u/4863358?v=4)](https://github.com/ateliee "ateliee (12 commits)")

---

Tags

mecab

### Embed Badge

![Health badge](/badges/youaoi-php-mecab/health.svg)

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

###  Alternatives

[nihongodera/limelight

A php Japanese language text analyzer and parser.

10678.9k](/packages/nihongodera-limelight)

PHPackages © 2026

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