Extract contents of zip files to a common folder /Library/Oracle/instantclient_11_2

The next step is to copy the necessary files into your OS X dynamic library and bin directories. Open a terminal window and go to the directory above the one you created containing all the files you unzipped.

Download the source for the version of php that you are using in MAMP (e.g.: 5.4.42 in this case).

Extract the PHP source file and move the created folder to the following location (based on PHP version): /Applications/MAMP/bin/php/php5.3.29/include/php. (The contents of the extracted folder should be in the root of ../include/php)

navigate to include/php folder and execute ./configure

Run sudo pecl install oci8

When Prompted, use instantclient,/Library/Oracle/instantclient_11_2/ as the Oracle instant Client path.

If you faced an error for AUTOCONF not found, (you don't have it installed in your MAC)

curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz

tar xzf autoconf-latest.tar.gz

cd autoconf-*

./configure --prefix=/usr/local

make

sudo make install

export PHP_AUTOCONF=/usr/bin/autoconf

rerun the same command

If all went well, the last line of the build process should say: You should add "extension=oci8.so" to php.ini

Open php.ini from /Applications/MAMP/bin/php/php5.3.29/conf and make the entry for extension=oci8.so at the end of the current extensions

Open /Applications/MAMP/Library/bin/envvars and add the path to the instant client library: DYLD_LIBRARY_PATH="/Library/Oracle/instantclient_11_2/:/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH”

Restart MAMP

Verify OCI8 library from phpinfo page

Connecting to Oracle Instance

PHP Connects to Oracle through OCI8 driver

OCI8 Driver relies on using tnsnames.ora

tnsnames.ora is expected under $TNS_ADMIN and/or /etc folder

Populate entry for your Oracle DB in tnsnames.ora

Note : If you maintain tnsnames.ora under both $ORACLE_HOME/network/admin and/or /etc folders ensure to keep them in Sync