PHPackages                             repat/mekras-php-speller - 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. repat/mekras-php-speller

ActiveLibrary

repat/mekras-php-speller
========================

PHP spell check library updated for PHP7

1.7.3(7y ago)228MITPHPPHP &gt;=7.1.3

Since May 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/repat/php-speller)[ Packagist](https://packagist.org/packages/repat/mekras-php-speller)[ RSS](/packages/repat-mekras-php-speller/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (3)Versions (15)Used By (0)

php-speller
===========

[](#php-speller)

PHP spell check library.

[![Latest Stable Version](https://camo.githubusercontent.com/f4a6565d359262f9347784499d4d8ae52a82cf2002bbf01af4a2447470b790c4/68747470733a2f2f706f7365722e707567782e6f72672f6d656b7261732f7068702d7370656c6c65722f762f737461626c652e706e67)](https://packagist.org/packages/mekras/php-speller)[![License](https://camo.githubusercontent.com/a71a1afdfad8feaefb3509d23e881dad78be94c336a8e9721d633468366ce184/68747470733a2f2f706f7365722e707567782e6f72672f6d656b7261732f7068702d7370656c6c65722f6c6963656e73652e706e67)](https://packagist.org/packages/mekras/php-speller)[![Build Status](https://camo.githubusercontent.com/5bdf878d30543a3f570fe9a26f30eb1d2fd374d757e33ae3733789fb7b3e7767/68747470733a2f2f7472617669732d63692e6f72672f6d656b7261732f7068702d7370656c6c65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mekras/php-speller)[![Coverage Status](https://camo.githubusercontent.com/5b2033061182503448e3622d3ad70bdb50909cae59b15acba825652febbda39d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6d656b7261732f7068702d7370656c6c65722f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/mekras/php-speller?branch=master)

Currently supported backends:

- [aspell](http://aspell.net/);
- [hunspell](http://hunspell.sourceforge.net/);
- [ispell](https://www.cs.hmc.edu/~geoff/ispell.html).

Installation
------------

[](#installation)

With [Composer](http://getcomposer.org/):

```
$ composer require mekras/php-speller

```

Usage
-----

[](#usage)

1. Create a text source object from string, file or something else using one of the `Mekras\Speller\Source\Source` implementations (see [Sources](#Sources) below).
2. Create some speller instance (Hunspell, Ispell or any other implementation of the `Mekras\Speller\Speller`).
3. Execute `Speller::checkText()` method.

```
use Mekras\Speller\Hunspell\Hunspell;
use Mekras\Speller\Source\StringSource;

$source = new StringSource('Tiger, tigr, burning bright');
$speller = new Hunspell();
$issues = $speller->checkText($source, ['en_GB', 'en']);

echo $issues[0]->word; // -> "tigr"
echo $issues[0]->line; // -> 1
echo $issues[0]->offset; // -> 7
echo implode(',', $issues[0]->suggestions); // -> tiger, trig, tier, tigris, tigress
```

You can list languages supported by backend:

```
/** @var Mekras\Speller\Speller $speller */
print_r($speller->getSupportedLanguages());
```

See [examples](examples/) for more info.

### Source encoding

[](#source-encoding)

For aspell, hunspell and ispell source text encoding should be equal to dictionary encoding. You can use [IconvSource](#IconvSource) to convert source.

Aspell
------

[](#aspell)

This backend uses aspell program, so it should be installed in the system.

```
use Mekras\Speller\Aspell\Aspell;

$speller = new Aspell();
```

Path to binary can be set in constructor:

```
use Mekras\Speller\Aspell\Aspell;

$speller = new Aspell('/usr/local/bin/aspell');
```

### Important

[](#important)

- aspell allow to specify only one language at once, so only first item taken from $languages argument in `Ispell::checkText()`.

Hunspell
--------

[](#hunspell)

This backend uses hunspell program, so it should be installed in the system.

```
use Mekras\Speller\Hunspell\Hunspell;

$speller = new Hunspell();
```

Path to binary can be set in constructor:

```
use Mekras\Speller\Hunspell\Hunspell;

$speller = new Hunspell('/usr/local/bin/hunspell');
```

You can set additional dictionary path:

```
use Mekras\Speller\Hunspell\Hunspell;

$speller = new Hunspell();
$speller->setDictionaryPath('/var/spelling/custom');
```

You can specify custom dictionaries to use:

```
use Mekras\Speller\Hunspell\Hunspell;

$speller = new Hunspell();
$speller->setDictionaryPath('/my_app/spelling');
$speller->setCustomDictionaries(['tech', 'titles']);
```

Ispell
------

[](#ispell)

This backend uses ispell program, so it should be installed in the system.

```
use Mekras\Speller\Ispell\Ispell;

$speller = new Ispell();
```

Path to binary can be set in constructor:

```
use Mekras\Speller\Ispell\Ispell;

$speller = new Ispell('/usr/local/bin/ispell');
```

### Important

[](#important-1)

- ispell allow to use only one dictionary at once, so only first item taken from $languages argument in `Ispell::checkText()`.

Sources
-------

[](#sources)

Sources — is an abstraction layer allowing spellers receive text from different sources like strings or files.

### FileSource

[](#filesource)

Reads text from file.

```
use Mekras\Speller\Source\FileSource;

$source = new FileSource('/path/to/file.txt');
```

You can specify file encoding:

```
use Mekras\Speller\Source\FileSource;

$source = new FileSource('/path/to/file.txt', 'windows-1251');
```

### StringSource

[](#stringsource)

Use string as text source.

```
use Mekras\Speller\Source\StringSource;

$source = new StringSource('foo', 'koi8-r');
```

Meta sources
------------

[](#meta-sources)

Additionally there is a set of meta sources, which wraps other sources to perform extra tasks.

### HtmlSource

[](#htmlsource)

Return user visible text from HTML.

```
use Mekras\Speller\Source\HtmlSource;

$source = new HtmlSource(
    new StringSource('Bar Baz')
);
echo $source->getAsString(); // Foo Bar Baz
```

Encoding detected via [DOMDocument::$encoding](http://php.net/manual/en/class.domdocument.php#domdocument.props.encoding).

### IconvSource

[](#iconvsource)

This is a meta-source which converts encoding of other given source:

```
use Mekras\Speller\Source\IconvSource;
use Mekras\Speller\Source\StringSource;

// Convert file contents from windows-1251 to koi8-r.
$source = new IconvSource(
    new FileSource('/path/to/file.txt', 'windows-1251'),
    'koi8-r'
);
```

### XliffSource

[](#xliffsource)

Loads text from [XLIFF](http://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html)files.

```
use Mekras\Speller\Source\XliffSource;

$source = new XliffSource(__DIR__ . '/fixtures/test.xliff');
```

Source filters
--------------

[](#source-filters)

Filters used internally to filter out all non text contents received from source. In order to save original word location (line and column numbers) all filters replaces non text content with spaces.

Available filters:

- [StripAllFilter](src/Source/Filter/StripAllFilter.php) — strips all input text;
- [HtmlFilter](src/Source/Filter/HtmlFilter.php) — strips HTML tags.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 98.9% 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 ~94 days

Recently: every ~137 days

Total

14

Last Release

2798d ago

PHP version history (3 changes)v1.00PHP ~5.4

v1.4PHP &gt;=5.5

1.7.3PHP &gt;=7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/405dab243007488e7e7851422e5864a9312aee36058d60f1e6d623232c4d3131?d=identicon)[repat](/maintainers/repat)

---

Top Contributors

[![mekras](https://avatars.githubusercontent.com/u/192067?v=4)](https://github.com/mekras "mekras (90 commits)")[![repat](https://avatars.githubusercontent.com/u/516807?v=4)](https://github.com/repat "repat (1 commits)")

---

Tags

spellingaspellhunspellispell

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/repat-mekras-php-speller/health.svg)

```
[![Health](https://phpackages.com/badges/repat-mekras-php-speller/health.svg)](https://phpackages.com/packages/repat-mekras-php-speller)
```

###  Alternatives

[mekras/php-speller

PHP spell check library

68409.5k](/packages/mekras-php-speller)[wapmorgan/morphos

A morphological solution for Russian and English language written completely in PHP. Provides classes to inflect personal names, geographical names, decline and pluralize nouns, generate cardinal and ordinal numerals, spell out money amounts and time.

8351.3M7](/packages/wapmorgan-morphos)[peckphp/peck

Peck is a powerful CLI tool designed to identify pure wording or spelling (grammar) mistakes in your codebase.

474325.3k97](/packages/peckphp-peck)[tigitz/php-spellchecker

Provides an easy way to spellcheck multiple text source by many spellcheckers, directly from PHP

309498.4k1](/packages/tigitz-php-spellchecker)

PHPackages © 2026

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