[solved] mysqli not found php spark migrate

I encountered this error while working on Codeigniter project.

I am using Mamp Pro on Mac OS Sonoma 14.3

My problem was multiple php versions was installed on system.

I could see mysqli enabled when doing this

<?php phpinfo() ?>

But when I tried to run following cli command to run migration

php spark migrate

I faced following error:

Unable to connect to the database. Main connection [MySQLi]: No such file or directory

And the problem was web browser was using different php version while cli was using different one. Because I have installed php using ‘brew install php’ command.

Check what php.ini is loading by running

php --ini

Update php path to Mamp one in ~/.bash_profile

That’s it!