How Enable The PHP Tidy Extension For MAMP

July 2010 ยท 2 minute read

1. Download the PHP source in according with your environment:

```
$ php -v
PHP 5.2.11 (cli) (built: Dec 12 2009 13:19:08)
```
  1. Extract in a temporary folder

    $ cd ~ && tar zxvf php-5.2.11.tar.gz && cd php-5.2.11
    
  2. 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
    
  3. 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"
    
  4. 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
    
  5. Configure & make

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

    $ cp ./modules/tidy.so /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/

  7. Enable the module in the /Applications/MAMP/conf/php5/php.ini adding the following line in the extension section:

    extension=tidy.so

  8. Restart the webserver

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

Reference Links:

comments powered by Disqus