OS X Monterey PHP 8.1 unable to find oci8.so

74 Views Asked by At

I downloaded and installed Oracle InstantClient from https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html, and installed it via the Instructions for OS X Monterey.

I then ran arch -arm64e pecl install oci8-3.2.1 for the proper version of oci8 to use with php 8.1 & Silicon, it reports that it has installed the oci8 extension and adds the so file.

However, when I run php -a, the first thing that pops up is that it can't find the oci8.so:

tried: /opt/homebrew/lib/php/pecl/20210902/oci8.so
(dlopen(/opt/homebrew/lib/php/pecl/20210902/oci8.so, 0x0009): 
symbol not found in flat namespace (_OCIAttrGet))

The oci8.so file exists at that location - I've tried reinstalling both php 8.1 and the oci extension, but still get the same error. Thx for any help!

1

There are 1 best solutions below

0
On BEST ANSWER

Sorted it out. For future reference: all pieces of the puzzle (Oracle, brew, php, oci8) need to be specifically set for Intel:

Download the Oracle InstantClient dmg(s) for OS X (Intel) and install per the documentation on the Oracle download page, then:

  1. Copy Terminal App, option-I and set as 'Open with Rosetta'
  2. In a Rosetta Terminal, install Homebrew: arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  3. Install [email protected]: arch -x86_64 /usr/local/Homebrew/bin/brew [re]install [email protected]
  4. Add the x86_64 [email protected] to your shell $PATH
  5. Install x86_64 oci8: arch -x86_64 pecl install oci8-3.2.1
  6. Add instantclient,[/full/path/to/installed/instantclient/directory] when prompted
  7. Add extension=oci8.so to php.ini if not automatically added after the PECL install, and extension_dir as needed
  8. php -a will return function_exists('oci_connect') as true

Note that the above installs the InstantClient for the cli only - you'll need additional configuration if you want to run a server using the Intel PHP; that info is in the output from the php install step.