PHP Pspell

The purpose of Pspell (Portable Spell Checker Interface Library) was to provide a generic interface to the system spelling checking libraries.

PHP’s Pspell extension, while retaining its current name, now uses the Aspell library.

Install

PHP PSpell extension installation is lacking documentation so your best bet is probably a google search for your OS.

Usage

Now that PHP PSpell extension is installed on your system, let's see how to spellcheck a word using PHP-Spellchecker and PHP PSpell extension.

Spellcheck

<?php

$phpPspell = new PHPPspell();

// en_US aspell dictionary is available
$misspellings = $phpPspell->check('mispell', ['en_US'], ['from_example']);
foreach ($misspellings as $misspelling) {
    $misspelling->getWord(); // 'mispell'
    $misspelling->getLineNumber(); // '1'
    $misspelling->getOffset(); // '0'
    $misspelling->getSuggestions(); // ['misspell', ...]
    $misspelling->getContext(); // ['from_example']
}

Or if you want to check a file instead:

<?php
// spellchecking a file
$misspellings = $phpPspell->check(new File('path/to/file.txt'), ['en_US'], ['from_file']);
foreach ($misspellings as $misspelling) {
    $misspelling->getWord();
    $misspelling->getLineNumber();
    $misspelling->getOffset();
    $misspelling->getSuggestions();
    $misspelling->getContext();
}

Available dictionaries

<?php

$phpPspell = new PHPPspell();

// Same one as aspell as it's using it underneath
$misspellings = $phpPspell->getSupportedLanguages();

Check the tests for more examples.