Ryan White
Ryan White

Reputation: 1917

Installing PHP Tidy on MAMP

MAMP and MAMP PRO does not come with php Tidy. This is a commonly used to clean up html.

Please post instructions for installing Tidy under MAMP. The current version of MAMP as of this post is 2.2. If there are specific instructions for different versions please post these as well.

Upvotes: 1

Views: 2575

Answers (2)

Ruth
Ruth

Reputation: 575

On 2023, MAMP 6.8 has the tidy.so in its php directories

you can append

extension={your MAMP application path}/bin/php/php{your_PHP_version}/lib/php/extensions/no-debug-{something}/tidy.so

in your php.ini file

I've tried with

[tidy]
extension="/Applications/MAMP/bin/php/php7.4.33/lib/php/extensions/no-debug-non-zts-20190902/tidy.so"
tidy.clean_output=0

and I can see the tidy extension enabled when running phpinfo();

Upvotes: 0

Ryan White
Ryan White

Reputation: 1917

Instructions for MAMP 2.2 with PHP 5.3.27

Most of this was lifted from: http://lucor.github.io/post/how-enable-the-php-tidy-extension-for-mamp/

NOTE: I already have OSX Dev tools installed (brew / XCode) so these may be required but they are not listed as I did not have a clean install.

Download PHP 5.3.27 http://www.php.net/get/php-5.3.27.tar.bz2/from/a/mirror If you want to use a different PHP version find that on http://www.php.net/releases/

Uncompress

tar xvjf php-5.3.27.tar.bz2
cd php-5.3.27

Setup compile flags 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.9 #Replace with your version.
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

Configure and Compile PHP This is the part that will build the lib. You will be throwing away everything except the tidy.so extension

LIBS=-lresolv ./configure --with-tidy=shared && make

Copy extension to MAMP php lib folder.

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

Configure PHP.ini to load extension. This can be done in the MAMP GUI as well. Since MAMP Pro recreates the php.ini upon server restart, you have to edit the template file.

echo "extension=tidy.so" >> /Library/Application\ Support/appsolute/MAMP\ PRO/conf/php.ini

Upvotes: 3

Related Questions