Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ashrulpuo/f54d67cbb5ead55cf938b3abc22802b9 to your computer and use it in GitHub Desktop.
Save ashrulpuo/f54d67cbb5ead55cf938b3abc22802b9 to your computer and use it in GitHub Desktop.
install Oracle PHP Extension (oracle OCI8) - instantclient for Mac OS 10.12.6 - homebrew environnement - on PHP 7.2

Installation

This procedure is tested on Mac OS Ventura | version 13.6.4

PHP 8.2 installed with Homebrew.

Preparation

Download the following files from Oracle website (yes, you need to create an account and accept terms):

  • In Finder, double click on all desired Instant Client .dmg packages to mount them. All installations require the Basic or Basic Light package.

Create and unzip all theses files into a the directory /usr/local/instantclient/19.16/.

Create symlinks

sudo ln -sfn /opt/oracle/instantclient_19.16/sdk/include/*.h /usr/local/include/
sudo ln -sfn /opt/oracle/instantclient_19.16/*.dylib /usr/local/lib/
sudo ln -sfn /opt/oracle/instantclient_19.16/*.dylib.19.1 /usr/local/lib/
sudo ln -sfn /usr/local/lib/libclntsh.dylib.19.1 /usr/local/lib/libclntsh.dylib

Install extension with pecl

pecl install oci8

If the script prompt you to provide the path to ORACLE_HOME directory, respond with:

instantclient,/opt/oracle/instantclient_19.16

On success installation, you will have messages like the following:

Build process completed successfully
Installing '/usr/local/Cellar/php@8.2/8.2.18/pecl/20220829/oci8.so'
install ok: channel://pecl.php.net/oci8-3.3.0
Extension oci8 enabled in php.ini

And your are done, normally pecl will automatically load the extension in your php.ini. If not, add the following line to your php.ini:

Run php --ini to check your php.ini file location.

extension=oci8.so

if you using laravel herd add the extension on php.ini file.

php.ini location in laravel herd : /Users/kocek/Library/Application Support/Herd/config/php/82

add OCI ext on php.ini file

extension=/usr/local/Cellar/php@8.2/8.2.18/pecl/20220829/oci8.so

Then you should see no more error message when runninng php -v.

Restart your HTTP Server and test.

Enjoy (or try to...) !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment