Skip to content

Instantly share code, notes, and snippets.

@steinbring
Last active June 13, 2024 18:53
Show Gist options
  • Save steinbring/e468dc84050b0dc83a6105c151dc286e to your computer and use it in GitHub Desktop.
Save steinbring/e468dc84050b0dc83a6105c151dc286e to your computer and use it in GitHub Desktop.
How to install the oci8 PHP plugin if you are using macOS and Laravel Herd
  1. There are two zip files on the Oracle website. Download them and unzip them into "/opt/oracle/instantclient_19_8". You will need to use "Grant Temporary Admin Rights" to create the folder.

    a. Basic Package (ZIP)

    b. SDK Package (ZIP)

  2. Use homebrew and pecl to install the PHP extension

    a. With homebrew installed, run "brew install php"

    b. Run "pecl search oci8" to get the latest stable version. As of the writing of this, the latest stable release is 3.3.0

    c. Run "pecl install oci8-X.X.X --with-oci8=instantclient,/opt/oracle/instantclient_19_8" (replacing X.X.X with the version number for the latest stable version). When it asked for the path to the ORACLE_HOME directory, give it "instantclient,/opt/oracle/instantclient_19_8". If this worked, the output should end in "Extension oci8 enabled in php.ini".

    d. The result should be 'oci8.so' being installed. Make a note of where it ended up. It is in '/opt/homebrew/Cellar/php/8.3.8/pecl/20230831/oci8.so' in my case but it might be different for you.

A screenshot of a computer Description automatically generated

  1. Activate the extension by editing the 'php.ini' in '~/Library/Application Support/Herd/config/php/<version>/'.

    a. If you click the Herd icon on the menu bar and then click "open configuration files", it should open the folder where you can do this.

    b. Once you get to this folder, you can add the extension definition to each php.ini file (example: "extension=/opt/homebrew/Cellar/php/8.3.8/pecl/20230831/oci8.so"

A screenshot of a computer menu Description automatically generated

A screenshot of a computer Description automatically generated

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