FAQ > PHP
Install a PHP Extension using PECL
MAMP PRO provides you with all the requirements to install PHP Extensions using PECL. This guide shows you how to install a PHP Extension via PECL using the mongodb extension and PHP 8.0.2 as an example.
- Open MAMP PRO and click on the “PHP” entry in the sidebar in the “Languages” area.
- Activate the “Activate command line shortcuts for the selected PHP version, pear & pecl” checkbox.
- Restart your servers. A PECL alias now exists in your “~/.profile”, “.profile” and “.zprofile” file.
- Open the Terminal app (/Applications/Utilities). Tip: If you have already opened the terminal app, then you must close and reopen it for the changes to the configuration files “~/.profile”, “.profile” and “.zprofile” to take effect.
- Change to the “/Applications/MAMP/bin/php/php8.0.2/bin” directory.
- Enter the following command and confirm your entry with Enter.
pecl install mongodb
If you are shown the message “Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONFenvironment variable. Then, rerun this script.”, then you need to perform the following steps:
Enter the following commands in the terminal and confirm each command with Enter. The asterisk at the command
autoconf-*stands for the corresponding version number (for example “2.71”).
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
Use the following commands in the Terminal to switch back up one directory level and restart the PHP extension installation process:
cd .. pecl install mongodb
Your PHP Extension should now build and you should see the following result:
Build process completed successfully Installing '/Applications/MAMP/bin/php/php8.0.2/lib/php/extensions/no-debug-non-zts-20200930/mongodb.so' install ok: channel://pecl.php.net/mongodb-1.9.1 configuration option "php_ini" is not set to php.ini location You should add "extension=mongodb.so" to php.ini
- A “mongodb.so” extension should now be in your “/Applications/MAMP/bin/php/php8.0.2/lib/php/extension/no-debug-non-zts-x” folder.
- Switch back to MAMP PRO and select “8.0.2” from the “File > Open Template > PHP (php.ini)” menu.
- The template for the php.ini file of PHP version 8.0.2 is opened. Insert the following line into it:
- Save and close the template.
- Restart your servers and verify the extension has been loaded by checking phpInfo. Please make sure that the host you use to call the phpInfo output is also set to the corresponding PHP version for which you have installed the PHP extension - in our case in this example this is PHP 8.0.2.