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:


  1. Download & Install (ASpell Win32)

  2. Download & Install (Win32 Dictionary File(s))

  3. Copy some DLL's on the server

  4. Enable the pspell extension in php.ini

  5. Restart the server

  6. 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";
}

< Back to Index

Permalink

http://www.oblius.com/blog/view.php?ID=612acab50e4cbc98b25704b418cf9d7f

This post has 33 comments.

Posted by Spazasaurus on December 21st, 2004:
You rock! I was struggling with getting it running and was getting more confused than anything else and within 5 minutes after finding this site, I was spell checking. Thanks!
Posted by Karl on January 10th, 2005:
A vey good tutorial for making it all work happily ever after. Much appreciated.
Posted by Pablo on March 4th, 2005:
Another common problem with ASpell on win32 is the error message:

&lt;filename&gt; is not in the proper format.

This can be resolved by converting all the files in the &quot;Program FilesASpelldata&quot; 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.
Posted by Mats Niska on March 29th, 2005:
Thanx, helped me a lot. BUT
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 &quot;en&quot;. in C:wwwphp2pspelltest.php on line 8
But by adding following line prior pspell_new:
$pspell_config = pspell_config_create(&quot;en&quot;);
The problem was solved using Apache/2.0.52 (Win32) PHP/5.0.3
Posted by wisdomb on April 12th, 2005:
Hi, and congratulations for your Blogs. I got the same error that Matt got, i did same thing but it did not work. So what should do, I am really stock?

ERROR:
Warning: pspell_new() [function.pspell-new]: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language &quot;en_US&quot;. 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
Posted by jean-luc on April 21st, 2005:
added aspell to my server and didn't came to have it working, as documentation on activating this hidden extension is very poor...
but reading your short and clear explanation solved my pb !
thanks for your help and post on this nice and smart weblog.
Posted by Jeff Stratton on May 4th, 2005:
Thanks! You sure made that a whole hell of a lot easier. Even for IIS!
Posted by Chris Jeffries on May 11th, 2005:
As well as adding thanks, I should say that with Apache 2 PHP 5, I still had to put the dll in the Win32 directory. It didn't work when it was just in the PHP directory.
Posted by oblius on May 11th, 2005:
Thanks for the tip on the DLL file!
Posted by shaki on May 17th, 2005:
Your page helped me a lot to enable pspell on Windows...I need help only with dictionary, from where I have to give reference to english dictionary?

thanks
Posted by shaki on May 17th, 2005:
from here you can see the test page, CGI Error that I get :(
http://www.getcv.com/testing.php
Posted by yur on May 23rd, 2005:
Can't find aspell-15.dll
I installed aspell, but system requires this *.dll
Posted by Marc on June 10th, 2005:
Great tutorial...your help was very much so apprecited.
Posted by Aritz on June 30th, 2005:
A lot of thanks! Very useful and great and easy tutorial!
Posted by saikumar on September 12th, 2005:
i downloaded aspell full installer for windows and install successfully. Also I installed dictionary pack for english , given in that site. But also,I am getting the following error :
&quot; Warning: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language &quot;en&quot;.&quot;. Can u explain this error. I need a clear explanation for this error. Thanks for your tutorial.
Posted by BMG on September 26th, 2005:
Much thanks for this guide!!!

Everything works great!!!
Posted by By Michelle on January 19th, 2006:
Very useful instruction. Thank you very much.
Posted by Daniel on April 10th, 2006:
I've followed your instructions, but when I try and run your test script, I get a Server Error 500...
Posted by Daniel on April 10th, 2006:
I've fixed my problem, I had PHP running as a CGI in Apache, I've changed it to run as a module, and not only has the aspell problem been fixed, but it's now running much much faster..
Posted by matt on May 15th, 2006:
Hi, (win xp pro sp2, apache 2.2.0, php5.1.2, zend 2.1.0)


I was having &quot;no dictionary&quot; 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(&quot;en&quot;); just before call to
$pspell_config = pspell_config_create(&quot;en&quot;);
and setting error_reporting(0) for the following reason.


With just

$pspell_config = pspell_config_create(&quot;en&quot;);

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 &quot;en&quot;


but with both calls

$pspell_config = pspell_new(&quot;en&quot;);
$pspell_config = pspell_config_create(&quot;en&quot;);

I was getting

PSPELL couldn't open the dictionary. reason: No word lists can be found for the language &quot;en&quot;.
....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.
Posted by Piers on July 19th, 2006:
After trying all the suggestions and doing a lot of poking around I got pspell to work on Windows with IIS by installing Aspell and then doing the following:
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 (&quot;pspell_comp.php&quot;);
}
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.
Posted by hopespoppa on July 19th, 2006:
aspell/pspell for PHP on Win32 IIS
Piers,
Please clarify...
&gt;&quot;Aspellinaspell.exe matches your installation path&quot;
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?


Posted by wsa on August 5th, 2006:
I cannot find the windows set up for the English dictionary anywhere? What am I missing? Thanks!
Posted by Fred on September 22nd, 2006:
If you have the error message :

Warning: pspell_new_config() [function.pspell-new-config]: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language &quot;en&quot;. in C:www est_pspell.php on line 4

Do the following to initialize the dictionnary:

[code]
$pspell_config = @pspell_new(&quot;en&quot;);
$pspell_config = pspell_config_create(&quot;en&quot;);
$pspell_link = pspell_new_config($pspell_config);
[/code]

Note: Don't forget the @ to suppress the false warning.

Hope this helps.
Posted by Søren - Peng - Pedersen on September 29th, 2006:
Great work, I followed this guide almost the the letter (except I use IIS 6) and the spelling sprang into action... thank you
Posted by Adam on August 8th, 2008:
I have been wrestling with pspell install on IIS for longer than I can remember! 5 mns on this site sorted it for me. Many thanks!
Posted by winning at roulette sites on July 23rd, 2009:
It is a regular windows setup program. Run it on the server which PHP resides on and follow the prompts to complete the installation. 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 A Spell onto....<a href="http://www.winningfunroulette.com">winning at roulette sites</a>
Posted by virtual roulette machines on July 23rd, 2009:
Really i am impressed from this post....the person who create this post he is a great human..thanks for shared this with us.i found this informative and interesting blog so i think so its very useful and knowledge able.I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in
the future as well.....
http://www.topvirtualroulette.com
Posted by Dragnovich on October 29th, 2009:
I found the solution for the "Dictionaries Not FOUND" this is basically a problem of WIndows/Unix compativility, Basically you need to change all your files in Aspell/data from dos to unix format (carriage return inconpatibility). The module try to read a unix file and get a windows file so it crash.

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.
Posted by Bernhard on November 16th, 2009:
Thanks a lot for this tutorial too!
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.



Posted by osama on February 28th, 2010:
good work
thank u
Posted by kp476 on April 5th, 2010:
i downloaded aspell full installer for windows and install successfully. Also I installed dictionary pack for english too.
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.

Posted by Jim on June 2nd, 2010:
I'm on windows 7 using WAMP. I kept getting a problem where phpinfo() was not reporting pspell as active (module was not showing up anywhere).
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.
Add a Comment to this Post
* Name
Email (optional)
* Comment
 

Enter the verification code shown below:

Verify