views:

208

answers:

2

I have installed MAMP and the PHP it came with wasn't compiled with ncurses. I've tried to use port to install ncurses and it seems that it already exists on my system so now I was wondering if there was a way to get PHP to use it without having to recompile PHP --with-ncurses.

In other words: Can PHP be configured to use ncurses without the recompilation?

+1  A: 

According to the manual, ncurses must be compiled in. Some extensions can be compiled as shared libraries (dll/so) and loaded dynamically, but some can't. Seems that ncurses can't.

I don't know a lot about how mac packages are structured, but isn't it a bsd/ports style installation? In that case, just find the package and configure + recompile it.

Edit: I see that mamp is a binary distribution. You're out of luck then. I would suggest that you install at least php from sources. It's very useful to be able to install new extensions etc. It's fairly straight forward to compile php, so even if you aren't completely confident with compiling stuff, you should be able to huddle through it.

troelskn
Thank you for your insightful and helpful answer.
Tom
Sorry, the question reopens until I verify @alexandermensa 's answer.
Tom
That's fine. His answer is much more detailed than mine.
troelskn
+1  A: 

Hello,

I'm sorry for the late answer but this can actually be done quite easily with MAMP.

I have done this on my MacBook running OS X Snow Leopard.

Your MAMP directory contains the tar file of the php source code. MAMP version 1.8.4 ships with php-5.2.11.tar located here: /Applications/MAMP/bin/php5/

  1. cd /Applications/MAMP/bin/php5/
  2. tar -xvf php-5.2.11.tar
  3. cd php-5.2.11/ext/ncurses
  4. /Applications/MAMP/bin/php5/bin/phpize
  5. ./configure --with-php-config=/Applications/MAMP/bin/php5/bin/php-config
  6. make
  7. make install

Afterwards you just need to add the ncurses.so extension to the MAMP php.ini

  1. echo "extension=ncurses.so" >> /Applications/MAMP/conf/php5/php.ini
  2. php -i | grep ncurses

This gives me:

ncurses

ncurses support => enabled

ncurses library version => 5.7

You can also do this with the PCNTL extension ;) ;)

Cheers!

alexandermensa
Thanks for the late reply, anyway. I am still interested in doing this, but the MAMP I am currently running came with PHP 5.2.6 and doesn't have the PHP .tar archive. When I get around to upgrading it to a newer full version, I will check out your reply. Again, thank you!
Tom
Chances are that the extensions haven't changed between `5.2.6` and `5.2.11`. Just follow the recipe and see if it works (Most likely it does)
troelskn