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:
- My machine is missing some necessary
mysqli.sofile. - 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...
The ini entry
extension=mysqli.sois required ifmysqliis compiled as a shared extension.All PHP brew formulae compile
mysqlistatically 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
mysqliis loaded correctly, you can run thephp -mcommand.