Skip to content
MAMP PRO Documentation

Install a PHP Extension using PECL

MAMP PRO provides all the requirements to install PHP extensions via PECL. This guide uses the mongodb extension and PHP 8.0.2 as an example.

  1. Open MAMP PRO and click on PHP in the Languages sidebar section.

  2. Set PHP 8.0.2 as the Default version.

  3. Enable Activate command line shortcuts for the selected PHP version.

  4. Restart the servers. A pecl alias is now added to ~/.profile, .profile, and .zprofile.

  5. Open Terminal (/Applications/Utilities/Terminal.app).

  6. Change to the PHP binary directory:

    cd /Applications/MAMP/bin/php/php8.0.2/bin
  7. Install the extension:

    pecl install mongodb
  8. If you see Cannot find autoconf, install it first:

    curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
    tar xzf autoconf-latest.tar.gz
    cd autoconf-*
    ./configure --prefix=/usr/local
    make
    sudo make install

    Then return to the PHP directory and retry:

    cd /Applications/MAMP/bin/php/php8.0.2/bin
    pecl install mongodb

    A successful build ends with output like:

    Build process completed successfully
    Installing '.../mongodb.so'
    install ok: channel://pecl.php.net/mongodb-1.9.1
  9. Verify that mongodb.so is in /Applications/MAMP/bin/php/php8.0.2/lib/php/extensions/no-debug-non-zts-20200930/.

  10. Open the PHP 8.0.2 template via File › Open Template › PHP (php.ini) › 8.0.2 and add:

    extension=mongodb.so

    MAMP PRO - Add extension to php.ini

  11. Save and close the template.

  12. Make sure the host you want to use is set to PHP 8.0.2.

  13. Restart the servers and verify the extension is loaded via phpinfo().

    MAMP PRO - phpInfo shows mongodb extension


PHP how-to guides