Abdul Rahman A Samad
Abdul Rahman A Samad

Reputation: 1152

MAMP: PHP -m shows oci8 enabled, but not in phpinfo

My objective is to connect to Oracle database through OCI8 which is available through:

pecl install oci8-2.0.11

To achieve that, I've been following various tutorials on the Net to make it work.

I followed the following tutorials:

  1. http://www.baldwhiteguy.co.nz/technical/index_files/mac-osx-oracle-instantclient.html
  2. http://www.enavigo.com/2012/01/04/enabling-oracle-oci8-php-extension-on-os-x-snow-leopard/
  3. http://tomytree22.blogspot.my/2014/09/oci-driver-installation-on-mac.html

These tutorials are enough to run SQL Plus. I am also able to successfully run pecl install oci-8.20.11 and get this output:

You should add "extension=oci8.so" to php.ini

In the 3rd tutorial I listed above, I followed all except under instantclient library has some hardcoded paths we need to take care of:

When I run php -m, I can see the oci8 is there, but I don't see it inside my phpinfo. What did I do wrong?

When I tried to connect to the Oracle database anyway, I am stuck with this:

Fatal error: Call to undefined function oci_connect()

I hope someone here can help me. I'm using El Capitan.

Upvotes: 2

Views: 5897

Answers (1)

Abdul Rahman A Samad
Abdul Rahman A Samad

Reputation: 1152

So I fixed it. Here's how I get to the solution.

I looked into my php log (make sure you enabled your PHP to log all errors! Just go to your error_log path to look for your error) and I found this:

[06-May-2016 09:48:12 Europe/Berlin] PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so' - dlopen(/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so, 9): Library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1

and

[09-May-2016 04:53:51 Europe/Berlin] PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so' - dlopen(/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so, 9): Library not loaded: /ade/dosulliv_ldapmac/oracle/ldap/lib/libnnz11.dylib

So oci8.so is not loaded because there are two libraries that are not loaded.

Here's how I fixed it:

And that means, the one that I skipped which is instantclient library has some hardcoded paths we need to take care of: is the one I needed. So I run these commands (copy pasted from the tutorial):

sudo mkdir -p /ade/b/3071542110/oracle/rdbms/lib/
sudo ln -sf /Applications/MAMP/bin/php/php5.5.10/lib/php/instantclient_11_2/libclntsh.dylib.11.1 /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1
sudo mkdir -p /ade/dosulliv_ldapmac/oracle/ldap/lib/
sudo ln -sf /Applications/MAMP/bin/php/php5.5.10/lib/php/instantclient_11_2/libnnz11.dylib /ade/dosulliv_ldapmac/oracle/ldap/lib/libnnz11.dylib

and then I restarted my MAMP. And now I got what I want, which is OCI8. Now the info is available on my PHPInfo.

My PHPInfo OCI8

Hope this will help the rest of guys who are embarking the same path of setting up OCI to connect to Oracle on MAMP.

Upvotes: 2

Related Questions