Is there any way to enable LDAP support on MAMP when running PHP 7.3 or higher on macOS?

I use MAMP 5.5 (383) on my macOS Catalina (10.15.6) for general PHP related development. Some of my projects require LDAP connectivity for various reasons.

My process works well using MAMP, but recently I noticed that if I switch from whoever PHP version I have available in either app from PHP 7.2 to PHP 7.3 or above, all LDAP support stops; I get errors like this:

[30-Jul-2020 23:59:14 America/New_York] PHP Fatal error:  Uncaught Error: Call to undefined function ldap_connect() in /Users/Jake/htdocs/ldap_test.php:3
Stack trace:
#0 {main}

And the only command in that file is simply a test ldap_connect() command.

In MAMP when I do a phpinfo() call, when it is running PHP 7.3.8 I see no LDAP references even in the configure command. But when I switch to PHP 7.2.21 I see --with-ldap in the configure command as well as this:

  • LDAP Support: enabled
  • RCS Version: $Id: 3839f871a91c293a52322c63329c68db23a0290a $
  • Total Links: 0/unlimited
  • API Version: 3001
  • Vendor Name: OpenLDAP
  • Vendor Version: 20428

Why is this?

I have tried to upgrade to MAMP 5.7 that has PHP 7.3 as well as PHP 7.4 but I get the same results; no LDAP support.

Has something happened in the way that OpenLDAP is supported in packages like this? I found this Homebrew related discussion which states the following and refers to this reported issue in an official PHP bug report:

“I can patch PHP 7.2 and older to use system LDAP again, but PHP 7.3 will require new symbols that only openldap exposes.”

Does this effectively mean that LDAP support in macOS is dead for PHP 7.3 and above unless there is a patch to PHP code or on the other side in the macOS implementation of OpenLDAP?

I use Ubuntu and CentOS as well and I can easily enable LDAP support via package installers there. But that’s little help when using MAMP for desktop development.


Looking for a solution that centers on the MAMP application and would like to avoid Homebrew or other setups where I am effectively building an M(acOS)AMP server from scratch on macOS.

Answer

Looks like this issue has been solved as of MAMP 6.3

LDAP support is back in the versions of PHP that come with MAMP 6.3 and higher.

Deciding to check a newer version of MAMP — since PHP 8 is looming and sticking with PHP 7.2 is no longer a real option — I downloaded MAMP 6.3 and it comes with PHP 7.4.12 and PHP 8.0.0 installed.

And without saying anything else… Both versions of PHP here have LDAP support baked in right out of the box! Confirmed by using a basic ldap_connect command as well as taking a few small apps I have developed around the block in these new versions of PHP and all works great!

So it seems like the PHP 7.3 cycles for MAMP had a weird “no-LDAP” blip. I recommend anyone wanting to move forward in their code, just download MAMP 6.3 and use PHP 7.4 at least and you should be solid.

The vendor version of LDAP contained in MAMP 6.3 is 20448 for anyone who needs to know that.

Leave a Reply

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