Unable to load dynamic library, PHP Homebrew MacOS

I am running MacOs M1 Chip and I have php8.2 installed via homebrew. I need maatwebsite/excel package for my project. Whenever I try to composer install/update it always says

enter image description here

and the composer install/update failed.

I have tried to enable the extensions in php.ini by removing the “;”, but the result is still the same.