Installing extension on Laravel Herd

To use any php extension, we should build ‘.so’ file for the extension.
Files with the “. so” extension are dynamically linked shared object libraries.

To start, you must install brew and pecl.

To install brew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

To install pecl:

brew install pecl

Then install php

brew install php

Once PHP is installed via Homebrew, you may install the extension:

pecl install [extension-name]

This creates an [extension].so extension file that you can now activate and use with Laravel Herd.

On an M1/M2 Mac, the extension can be fount at /opt/homebrew/lib/php/pecl.
On an Intel Mac, it will be at /usr/local/lib/php/pecl.

You may activate your custom extensions by editing your php.ini file. This file is located at ~/Library/Application Support/Herd/config/php/<version>/php.ini..

# Absolute path to the extension.so file
extension=/opt/homebrew/lib/php/pecl/20220829/[extension].so

if you are using m2 mac, you can use these mongodb and xdebug extensions.

https://github.com/realanmup/herd-extensions

as i am using mac m2, you can request more extensions from issues page on gitlab.

https://github.com/realanmup/herd-extensions/issues