I am using PHP 8
on Xampp (Windows)
Have added extension=php_enchant.dll
to php.ini
- php directory added to windows PATH
- copied
libenchant_hunspell.dll / libenchant_ispell.dll / libenchant_myspell.dll
to[php]/lib/enchant
- moved
*.dic
&*.aff
to[php]/share/myspell/dicts
But still cannot get Enchant to detect Brokers
sample code
<?php
$broker = enchant_broker_init();
$tag = 'en_US';
$bprovides = enchant_broker_describe($broker);
echo "Current broker provides the following backend(s):\n";
print_r($bprovides);
Output
Current broker provides the following backend(s): Array ( ) Current broker provides the following dictionaries: Array ( )
I ran into the same problem. I am moderately skilled in the PHP core and after a few days of debugging this I finally got it to work. Unfortunately, there seem to be quite a few changes in both lib_enchant and in PHP 8.
lib_enchant 2.x and PHP 8 (on Windows) seem to only support the hunspell provider (PHP 7.x and previous was using both ispell and myspell providers). Further, it seems that enchant now hard codes the path to the provider DLLs to:
So, you must locate libenchant2_hunspell.dll which is in the PHP distro in the lib/enchant folder to:
Similarly the location of the dictionary files defaults to:
So in my case I ended up with the following files in that folder:
In my review of the sources for enchant it seems you might be able to control the location of the spell check dictionaries via the environment variable ENCHANT_CONFIG_DIR but I believe the provider location is now hard coded. This is new with lib_enchant 2.x and PHP 8 ... and a huge hassle for us because we do not want to install software in c:\usr\local on a Windows machine.
I will probably work up a patch and submit it to PHP to fix this but I am concerned they will not accept it because the patch will really be in lib_enchant. PHP does host their own copy of lib_enchant on github for building dependencies like this so perhaps they will integrate the changes.
I hope this helps others.