Search code examples
phpmampaspellpspell

How to Install pspell with MAMP


I use MAMP for local php development and recently needed to use php's pspell functions for a project. I found little help with this specific scenario (short of recompiling php, yuck) so this post explains how I got it done.


Solution

    1. I am not positive but you may need xcode and xcode command line tools installed for this to work. This article might be helpful.

    2. Install MacPorts if you don't have it already

    3. Install aspell and the dictionary of your choice (I used "en"):

      sudo port install aspell aspell-dict-en

    4. note: for the next commands, you need to know the version of php you're running on MAMP. You can find this in the MAMP preferences under the PHP tab. For me it's 5.5.18

      Download the php source for the version of php you are running, unarchive it, and move into the pspell source directory:

      cd ~/Downloads/php-5.5.18/ext/pspell

    5. Now (being sure to use the proper phpize binary for your php version) do:

      /Applications/MAMP/bin/php/php5.5.18/bin/phpize

    You should see something like:

     Configuring for:
     PHP Api Version:         20121113
     Zend Module Api No:      20121212
     Zend Extension Api No:   220121212
    

    Next:

    ./configure --with-php-config=/Applications/MAMP/bin/php/php5.5.18/bin/php-config --with-pspell=/opt/local/

    And finally, build the module file:

    make
    
    1. You should now have two files inside the ./modules/ directory: aspell.so and aspell.la - copy them into your php's extensions directory:

      cp ./modules/* /Applications/MAMP/bin/php/php5.5.18/lib/php/extensions/no-debug-non-zts-20121212

    2. Now add the extension to your configuration file in /Applications/MAMP/bin/php/php5.5.18/conf/php.ini

      extension=pspell.so

    3. Finally, restart your MAMP servers and (hopefully) you are good to go!