Pspell (aspell)

The pspell extension is often the first found. It uses the aspell library and its dictionaries. Usage is very simple:

$dict2 = pspell_new('fr');
$word  = $_SERVER['argc'] > 1 ? $_SERVER['argv'][1] : 'France';
if (pspell_check($dict2, $word)) {
    printf("Aspell   checks '%s': OK\n", $word);
} else {
    printf("Aspell   suggests for '%s': %s\n", $word, implode(', ', pspell_suggest($dict2, $word)));

Unfortunately, this library is no more maintained (since 2011) and if still available in RHEL and CentOS, its dictionaries are not available in the repositories, which makes its usage nearly impossible.

Enchant (hunspell)

The enchant extension is an alternative. It uses the enchant library and the hunspell dictionaries. Usage is also very simple:

$broker = enchant_broker_init();
$dict1  = enchant_broker_request_dict($broker, 'fr_FR');
$word   = $_SERVER['argc'] > 1 ? $_SERVER['argv'][1] : 'France';
if (enchant_dict_check($dict1, $word)) {
    printf("Hunspell checks '%s': OK\n", $word);
} else {
    printf("Hunspell suggests for '%s': %s\n", $word, implode(', ', enchant_dict_suggest($dict1, $word)));

Dictionaries, used for example by LibreOffice or Firefox, are complete and available in official repositories.


To facilitate the use of old applications which still use pspell, and as the question comes quite often, I just added all the dictionaries in the remi-safe repository  (aspell-* )

I think enchant should be preferred, and, when needed, the code adaptation is very simple.