codeconjure/php-hunspell 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

codeconjure/php-hunspell

Composer 安装命令:

pie install codeconjure/php-hunspell

包简介

PHP binding for the Hunspell spell-checker and morphological analyzer

README 文档

README

CI

PHP 8.2+ binding for the Hunspell spell-checker and morphological analyzer. Exposes spell-check, suggestions, morphological analysis (analyze, stem, generate), runtime dictionary mutation (add, addWithAffix, remove, addDictionary), and dictionary metadata.

Requirements

  • PHP 8.2 or newer (NTS or ZTS)
  • libhunspell 1.6.0 or newer + its development headers
  • pkg-config
  • A C++17-capable compiler

Install via PIE (recommended)

pie install codeconjure/php-hunspell

Install via phpize

git clone https://github.com/connorhu/php-hunspell.git
cd php-hunspell
phpize
./configure --enable-hunspell
make
sudo make install
echo "extension=hunspell.so" | sudo tee /etc/php/conf.d/hunspell.ini

Usage

<?php
$dict = new Hunspell\Dictionary('/path/to/hu_HU.aff', '/path/to/hu_HU.dic');

$dict->spell('szótár');                   // bool
$dict->suggest('szóter');                 // list<string>
$dict->stem('szótárak');                  // list<string>
$dict->analyze('szótárak');               // list<Hunspell\Analysis>

$a = $dict->analyze('szótárak')[0];
$a->getRaw();                             // raw morph string
$a->getFields();                          // array<string, list<string>>
$a->get('st');                            // stems (list<string>)
$a->has('hy');                            // bool — does this analysis carry a hyphenation hint?

$dict->generate('ház', 'kertben');        // generate form of ház matching kertben's morphology
$dict->addWithAffix('Németh', 'világ');   // proper noun inherits világ's affix flags

Error handling

try {
    $dict = new Hunspell\Dictionary($aff, $dic);
} catch (Hunspell\Exception\Exception $e) {
    // Any Hunspell-layer failure (currently only DictionaryLoadException)
}

License

PHP License 3.01.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: C++

其他信息

  • 授权协议: PHP-3.01
  • 更新时间: 2026-05-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固