Go to https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html
Download the following zip files according to the required version
instantclient-basic-macos.x64-19.8.0.0.0.zip
instantclient-sqlplus-macos.x64-19.8.0.0.0.zip
instantclient-sdk-macos.x64-19.8.0.0.0.zip
Unzip the content of the three zip files, for example on the Downloads folder ~/Downloads/instantclient_19_8
In this case I'm using MAMP with PHP 7.4.12:
So the path I'm using is /Applications/MAMP/bin/php/php7.4.12
Copy all the content of ~/Downloads/instantclient_19_8 to /Applications/MAMP/bin/php/php7.4.12/lib/php/instantclient_19_8
Then install/compile oci8 with pecl
cd /Applications/MAMP/bin/php/php7.4.12/bin
sudo ./pecl install oci8-2.2.0 --with-oci8=instantclient,/Applications/MAMP/bin/php/php7.4.12/lib/php/instantclient_19_8
If prompted for the "Please provide the path to the ORACLE_HOME directory" just type:
instantclient,/Applications/MAMP/bin/php/php7.4.12/lib/php/instantclient_19_8
If evethings goes well it shows a message like this:
Build process completed successfully
Installing '/Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/oci8.so'
install ok: channel://pecl.php.net/oci8-2.2.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini
Manually enable oci8 extension in the php.ini file
vim /Applications/MAMP/bin/php/php7.4.12/conf/php.ini
# Then add extension="oci8.so" to the file
extension="oci8.so"
Save the php.ini file and restart MAMP
If you look on MAMP PHP Info you should be able to see OCI8 Driver Available:
Based on
http://tomytree22.blogspot.com/2014/09/oci-driver-installation-on-mac.html
https://gist.github.com/gido/5237100
In my particular case, I'm using Yii2 Framework I've looking for PDO OCI for develop with MAMP AND PHP 7.4.2, but it has been a difficult task, finally after searching in a lot of Google results, there's a related issue of this in Yii2 Repository and there's a comment that suggest few composer extensions to emulate PDO OCI, I tried https://www.yiiframework.com/extension/yii2-osi8pdo and it's working as expecetd on my dev environment
As @samdark suggested, there are more
- https://github.com/yajra/pdo-via-oci8
- https://github.com/intersvyaz/pdo-oci8
- https://github.com/apaoww/yii2-oci8
- https://github.com/SergioMadness/oci8Pdo
- https://github.com/neutrinobg/yii2-oci2pdo
- https://github.com/crazycodr/pdo-via-oci8
- https://github.com/nineinchnick/pdo_oci8
- https://github.com/alfmel/pdo-via-oci8
Amazing and straight forward step by step installation.