FAQ > PHP

Install a PHP extension using PECL

Use the following guideline to compile your own extensions. This example uses the mongodb extension and PHP 7.0.15. You can find more PHP extensions here.

  1. Check the “Activate command line shortcuts for the selected PHP version, pear & pecl” check box on your Languages > PHP tab.

  2. Restart your servers. A PECL alias now exists in your “~/.profile” and “.profile” file.

  3. Open Terminal.app (/Applications/Utilities) change the directory to “/Applications/MAMP/bin/php/php[Version]/bin” and enter the following line into the terminal and hit enter:

    pecl install mongodb

    If you see the message “Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.” then you must first run the following commands:

    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
    

    Your extension should now build and you should see the following result:

    Build process completed successfully
    Installing '/Applications/MAMP/bin/php/php7.4.8/lib/php/extensions/no-debug-non-zts-20190902/mongodb.so'
    install ok: channel://pecl.php.net/mongodb-1.8.0
    configuration option "php_ini" is not set to php.ini location
    You should add "extension=mongodb.so" to php.ini
    
  4. A “mongodb.so” extension should now be in your /Applications/MAMP/bin/php/phpVERSION/lib/php/extension/no-debug-non-zts folder.

  5. Go to “File > Open Templates > PHP > VERSION” and add “extension=mongodb.so”.

    MAMP PRO - Install a PHP extension using PECL - Add extension to .ini file

  6. Restart your servers and verify the extension has been loaded by checking phpInfo.

    MAMP PRO - Install a PHP extension using PECL - phpInfo