How Enable The PHP Tidy Extension For MAMP

How Enable The PHP Tidy Extension For MAMP

July 20, 2010
  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
  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"
    #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:

    $ 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"
  6. Configure & make

    $ LIBS=-lresolv ./configure --with-tidy=shared && make
  7. Copy the module in MAMP

    $ cp ./modules/ /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:
  9. Restart the webserver

  10. Check with php_info() if the tidy extension is loaded correctly

Reference Links: