How enable the PHP Tidy extension for MAMP

  1. Download the PHP source in according with your environment:
    $ php -v
    PHP 5.2.11 (cli) (built: Dec 12 2009 13:19:08)
    
  2. Extract in a temporary folder
    $ cd ~ && tar zxvf php-5.2.11.tar.gz && cd php-5.2.11
    
  3. Patch the ext/iconv/iconv.c file remove the lib on #define iconv libiconv so that the code reads like this:
    #ifdef HAVE_LIBICONV
    #define iconv iconv
    #endif
  4. Patch the ext/tidy/tidy.c file moving the line 34: #include “tidy.h” to line 24 of tidy.c so that the code reads like this:
    #ifdef HAVE_CONFIG_H
    #include "config.h"
    #endif
    
    #include "tidy.h"
    #include "php.h"
    #include "php_tidy.h"
    
    #if HAVE_TIDY
    
    #include "php_ini.h"
    
  5. Instruct the system to build universal binaries, that will work on both 32 and 64 bit systems by entering the following commands in the terminal console:
    $ MACOSX_DEPLOYMENT_TARGET=10.6
    $ CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
    $ CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
    $ LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
    $ export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
  6. Configure & make
    $ LIBS=-lresolv ./configure --with-tidy=shared && make
  7. Copy the module in MAMP
    $ cp ./modules/tidy.so /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/
  8. Enable the module in the /Applications/MAMP/conf/php5/php.ini adding the following line in the extension section:
    extension=tidy.so
  9. Restart the webserver
  10. Check with php_info() if the tidy extension is loaded correctly ;-)

Reference Links:

Tags: , , ,

  1. Josue Rodriguez’s avatar

    Sir, you are brilliant!!

    Also, please note that in MAMP 1.9 Pro, you a need to add the line “extension=tidy.so” in the following ini files as well:

    /Applications/MAMP PRO 1.9/MAMP PRO.app/Contents/Resources/php52.ini
    …and…
    /Applications/MAMP PRO 1.9/MAMP PRO.app/Contents/Resources/php53.ini

  2. lebogang nkoane’s avatar

    Hello,

    ta for the help — alas, I only changed this ext/tidy/tidy.c as you specified

    then ran: ./configure && make && sudo make install —> then added: extension=tidy.so to php.ini

    and it worked.

    *caveat: I am not using the MAMP App — custom MAMP stack.

    So, yeah — thank you for that tip, made my day!

  3. Christian’s avatar

    Thank you Luca. Saved me a lot of time.

Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>