Install Mongodb on PHP Mac OS Montery (M1)

ilhamsabir

ilhamsabir

Posted on March 13, 2024

Install Mongodb on PHP Mac OS Montery (M1)

Install Mongodb on PHP Mac OS Montery (M1)

Install the PHP MongoDB Extension before installing the PHP Library for MongoDB. It is worth noting, that full MongoDB driver experience is provided by installing both the low-level extension (which integrates with our C driver) and high-level library, which is written in PHP.

But to make windows terminal look beauty we need to add a theme, so lets start.

Prerequisites

  • Install PECL

    brew install pecl
    
  • Install pcre2

    brew install pcre2
    

Tutorial

  • Install mongodb extension

    pecl install mongodb
    
  • Enabled extension on PHP.ini

    extension=mongodb.so
    
  • To verify installation.

    php -i | grep mongodb
    
  • You shoul see output.

    $ php -i|grep mongo
    mongodb
    libmongoc bundled version => 1.17.2
    libmongoc SSL => enabled
    libmongoc SSL library => Secure Transport
    libmongoc crypto => enabled
    libmongoc crypto library => Common Crypto
    libmongoc crypto system profile => disabled
    libmongoc SASL => enabled
    libmongoc ICU => disabled
    libmongoc compression => enabled
    libmongoc compression snappy => enabled
    libmongoc compression zlib => enabled
    libmongoc compression zstd => enabled
    libmongocrypt bundled version => 1.0.4
    libmongocrypt crypto => enabled
    libmongocrypt crypto library => Common Crypto
    

Error

When error appear.

  • Copy pcre2 to your php dir
  cp /opt/homebrew/Cellar/pcre2/10.xxxx/include/pcre2.h /opt/homebrew/Cellar/php@7.xxx/7.xxx/include/php/ext/pcre/pcre2.h
Enter fullscreen mode Exit fullscreen mode

notes Change pcre2 version & php version with your local machine version.

  • Run

    sudo pecl install mongodb
    
  • It should fix your error.

Source

💖 💪 🙅 🚩
ilhamsabir
ilhamsabir

Posted on March 13, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related