Cannot install / restore mysqli with [email protected] using Homebrew

116 Views Asked by At

I am trying to connect my PHP Laravel app using Illuminate to a MySQL database. To do this, I need the mysqli extension to work. However, after uncommenting the line to do so in my php.ini file:

extension=mysqli.so

...even this results in many commands (e.g. php --ini, etc.) resulting in the following output:

PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli' (tried: /opt/homebrew/lib/php/pecl/20220829/mysqli (dlopen(/opt/homebrew/lib/php/pecl/20220829/mysqli, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20220829/mysqli' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/php/pecl/20220829/mysqli' (no such file), '/opt/homebrew/lib/php/pecl/20220829/mysqli' (no such file)), /opt/homebrew/lib/php/pecl/20220829/mysqli.so (dlopen(/opt/homebrew/lib/php/pecl/20220829/mysqli.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20220829/mysqli.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/php/pecl/20220829/mysqli.so' (no such file), '/opt/homebrew/lib/php/pecl/20220829/mysqli.so' (no such file))) in Unknown on line 0

Some investigation of these directories on my mac lead me to believe that:

  1. My machine is missing some necessary mysqli.so file.
  2. Whenever I try to install the missing library, homebrew complains that there is no such library/extension called "mysqli":
ryan@Ryans-MacBook-Pro ~ % brew install php-mysqli

Warning: No available formula with the name "php-mysqli". Did you mean php-zts?
==> Searching for similarly named formulae and casks...
==> Formulae
shivammathur/php/php-zts

To install shivammathur/php/php-zts, run:
  brew install shivammathur/php/php-zts

I expect there must be some way to install mysqli onto my mac...

1

There are 1 best solutions below

0
Shivam Mathur On

The ini entry extension=mysqli.so is required if mysqli is compiled as a shared extension.

All PHP brew formulae compile mysqli statically with the PHP binary, so this line is not required and should be removed. That will remove the PHP Warning you are getting.

Then, to check if mysqli is loaded correctly, you can run the php -m command.