Blog of Death
Enabling pspell for PHP on Win32
November 23rd, 2004
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 (currently GNU Aspell-0.50.3 (win32)). 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 and 5.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:
extension=php_pspell.dll
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. Test it out!
$pspell_link = pspell_new("en");
if (pspell_check($pspell_link, "testt"))
{
echo "This is a valid spelling";
}
else
{
echo "Sorry, wrong spelling";
}
Permalink
http://www.oblius.com/blog/view.php?ID=612acab50e4cbc98b25704b418cf9d7f

<filename> is not in the proper format.
This can be resolved by converting all the files in the "Program FilesASpelldata" directory from dos to unix format. Search google for dos2unix.exe and you will find a utility that can do it. This will resolve the error.
I got following error:
Warning: pspell_new() [function.pspell-new]: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en". in C:wwwphp2pspelltest.php on line 8
But by adding following line prior pspell_new:
$pspell_config = pspell_config_create("en");
The problem was solved using Apache/2.0.52 (Win32) PHP/5.0.3
ERROR:
Warning: pspell_new() [function.pspell-new]: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en_US". in C:Program FilesApache GroupApache2htdocsPrueba1.php on line 10
Warning: pspell_check() [function.pspell-check]: 0 is not a PSPELL result index in C:Program FilesApache GroupApache2htdocsPrueba1.php on line 12
Sorry, wrong spelling
Thanks for you help!
Apache/2.0.53 (Win32) PHP/5.0.3
but reading your short and clear explanation solved my pb !
thanks for your help and post on this nice and smart weblog.
thanks
http://www.getcv.com/testing.php
I installed aspell, but system requires this *.dll
" Warning: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en".". Can u explain this error. I need a clear explanation for this error. Thanks for your tutorial.
Everything works great!!!
I was having "no dictionary" errors. Funny thing on restart of apache2 with php as module, it made the call once successfully, then errors again until restart! Anyway solved this by reinstalling aspell into a folder within apaches doc root (as stated in httpd.conf), adding
$pspell_config = pspell_new("en"); just before call to
$pspell_config = pspell_config_create("en");
and setting error_reporting(0) for the following reason.
With just
$pspell_config = pspell_config_create("en");
the error was
pspell_new_config() [function.pspell-new-config]: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en"
but with both calls
$pspell_config = pspell_new("en");
$pspell_config = pspell_config_create("en");
I was getting
PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en".
....and then the list of words with spellings as expected!!
So I ended up just setting
error_reporting(0);
the whole thing works but it aint pretty.
Any ideas welcome.
I am not impressed with this extension, there are no config flags, so its hit or miss and copy this that and the other to various places until it works.
If you are used to and happy locking down exec, it might be worth writing a wrapper for an exec call to apres and leaving out the middle man (pspell) entirely.
1) DON'T include the extension=php_pspell.dll line in PHP.ini
2) Include the following code prior to any pspell commands:
if(!function_exists('pspell_suggest'))
{
// Set the path to aspell if you need to use it.
define('ASPELL_BIN','Aspellinaspell.exe');
require_once ("pspell_comp.php");
}
Make sure that Aspellinaspell.exe matches your installation path!!!
3) get a copy of pspell_comp.php
This is originally from splibrain.org but I got a copy included with Ajax Spell from
http://www.broken-notebook.com/spell_checker/download.php
Doing the above will cause Aspell to be called directly and gets round whatever is fouling up the pspell.dll
I have some concerns about the efficiency of this in a Production environment (live server) but since I don't run public webservers on Windows I'm only using it for development. Obviously when you run the code on a live server with pspell installed corrrectly then the compatibility library won't be called. Hope this helps! I've googled hard and for my setup none of the fixes I've found anywhere would solve the problem.
Piers,
Please clarify...
>"Aspellinaspell.exe matches your installation path"
aspell win32 installer places apspell application in c:programs by default, so where should pspell_comp.php be placed? in c:phpini or c:aspellin?
Warning: pspell_new_config() [function.pspell-new-config]: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en". in C:www est_pspell.php on line 4
Do the following to initialize the dictionnary:
[code]
$pspell_config = @pspell_new("en");
$pspell_config = pspell_config_create("en");
$pspell_link = pspell_new_config($pspell_config);
[/code]
Note: Don't forget the @ to suppress the false warning.
Hope this helps.
the future as well.....
http://www.topvirtualroulette.com
To test WHICH files you need to change simply run your php script from Dos prompt (CMD).
for example:
c:\> php test.php
Unhandled Error: The file "C:\Program Files\Aspell\data/standard.kbd" is
not in the proper format.
So you need to convert standard.kdb from unix to dos.
I Used Notepadd++ > Format > Unix format
For more options check this page:
http://kb.iu.edu/data/acux.html
An implementation of this module is available at:
http://secrebot.com/
Your Online Personal Secretary, totally automate and you will be able to chat with her.
I used it to get it work on ubuntu server. All you have to do here is:
- apt-get install php5-pspell
- apt-get install aspell
download the dictionairis from the above mentioned page and follow the instructions in the readme-files.
thank u
After that i even copied the aspell-15.dll in system32 folder too and changed the php.ini file too.. but m still getting error.. It prompts unhandled error.
Again i repeated the procedure and this time i even copied aspell-15.dll in php folder too..
Still getting error.
I tried adding pspell-15.dll to System32, with no luck. I then saw my path referred to it as system32 (lowercase s). So I just added the aspell bin dir to my path and it worked.
I also found that BOTH aspell-15.dll AND aspell-15.dll were needed.