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.


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


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.



$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:

// spellchecking a file
$misspellings = $phpPspell->check(new File('path/to/file.txt'), ['en_US'], ['from_file']);
foreach ($misspellings as $misspelling) {

Available dictionaries


$phpPspell = new PHPPspell();

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

Check the tests for more examples.