Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aniketmagadum's avatar

MongoDB php extension installation failed on MacOs

I am trying to install the MongoDB PHP Extension in my new MacBook Air M1. I am facing the following error during installation

The command I am using for installation

sudo pecl install mongodb

The error I am facing

/opt/homebrew/Cellar/php/8.0.9/include/php/ext/pcre/php_pcre.h:23:10: fatal error: 'pcre2.h' file not found
#include "pcre2.h"
         ^~~~~~~~~
1 error generated.
make: *** [php_phongo.lo] Error 1
ERROR: `make' failed

Here is the output of which php and which pecl command

aniketmagadum@Anikets-MacBook-Air bin % which php
/opt/homebrew/bin/php
aniketmagadum@Anikets-MacBook-Air bin % which pecl
/opt/homebrew/bin/pecl

The PHP Version I am using

aniketmagadum@Anikets-MacBook-Air bin % php -v
PHP 8.0.9 (cli) (built: Jul 29 2021 08:52:24) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies
aniketmagadum@Anikets-MacBook-Air bin % 
0 likes
2 replies
aniketmagadum's avatar

Thanks @neilstee This command solved the issue

ln -s /opt/homebrew/Cellar/pcre2/10.37_1/include/pcre2.h /opt/homebrew/Cellar/php/8.0.9/include/php/ext/pcre/pcre2.h

2 likes

Please or to participate in this conversation.