Enabling aspell/pspell on PHP running on a Windows machine has generated a bit of confusion because of the lack of documentation in doing this. But I have found that the following procedure worked for me flawlessly with PHP 5.02 / Win32 (this will probably work identically for PHP 4.3.x as well - but no guarantees).
Basic Steps:
- Download & Install (ASpell Win32)
- Download & Install (Win32 Dictionary File(s))
- Copy some DLL’s on the server
- Enable the pspell extension in php.ini
- Restart the server
- Test it out
1. Download and Install ASpell Win32
Browse to the ASpell Win32 site and download the latest ‘Full installer’ version for Win32 english is currently ( aspell-en-0.50-2-3.exe ). It is a regular windows setup program. Run it on the server which PHP resides on and follow the prompts to complete the installation.
2. Install a Dictionary / Dictionaries
Download dictionary files for the languages you need to support from the same page you downloaded the ASpell binaries from. You need at least one dictionary installed (I installed the English dictionary.) Run the windows setup program for the dictionary(ies) on the server you installed ASpell onto. The folder for ASpell should be automatically detected by the dictionary setup program - so you can generally just keep hitting ‘Next’ until it’s installed.
3. Copy ASpell DLL’s to System32
Browse to the /bin/ folder in the ASpell program directory (default is C:\Program Files\ASpell\bin) and copy the aspell-15.dll to your %Win32%/System32 folder (i.e. like you would for files like php4apache2.dll, etc.)
NOTE: In PHP 5.x you can probably copy aspell-15.dll to the root PHP folder as well,
but for compatibility with PHP 4.x, use %Win32%/System32/.
4. Edit php.ini and enable the pspell extension
Open up your php.ini and find the block where you enable extensions. I’ve noticed that in both PHP 4.3.x and 5.0.x, the pspell extension DLL isn’t in the list of commented-out extensions. However, the DLL file is provided with the PHP package and should be found in your extensions folder under “php_pspell.dll”. Thus, you must manually add a line to load this extension:
PHP.ini
5. Restart Apache
Restart Apache and verify that it came up properly. It should, but if not, double-check your spelling of the extension in php.ini and that you’ve copied the aspell DLL files to the System32 folder.
6. PHP : Test it out!
if (pspell_check($pspell_link, “testt”))
{
echo “This is a valid spelling”;
}
else
{
echo “Sorry, wrong spelling”;
}
7. Error on some windows machines
To get round the error on Windows where the word list can’t be found inside functions, take the call to pspell_new() out of the function and pass the return value to your function, i.e.
PHP
echo pspell_check($pspell_link, “test”) ? ‘OK’ : ‘Not OK’;
}
$pspell_link = pspell_new(”en”);
testSpell($pspell_link);




