Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

toby's avatar
Level 31

Valet 4.0 (PHP 8.2) w/ Oracle OCI8 on Apple Silicon

Hi everyone,

For local dev, I want to move from homestead to Valet 4.0. For some applications, I need to connect to a Oracle database; on homestead, this works after installing the instantclient-sdk and instantclient-basic as well as installing the OCI-module via PECL.

Unfortunately, this does not work on macOS running on Apple Silicon... Do you have any tips on how to install OCI8 on macOS with Apple Silicon running PHP 8.2?

Thanks in advance!

0 likes
5 replies
LaryAI's avatar
Level 58

After some research, it seems that the Oracle OCI8 extension is not yet compatible with PHP 8.1 and 8.2 on Apple Silicon. However, there is a workaround that involves using Docker to run a Linux container with PHP 7.4 and the OCI8 extension installed.

Here are the steps to follow:

  1. Install Docker Desktop for Mac on your Apple Silicon machine.

  2. Create a new directory for your project and navigate to it in the terminal.

  3. Create a new file called Dockerfile with the following contents:

FROM php:7.4-cli

RUN apt-get update && \
    apt-get install -y libaio1 unzip && \
    mkdir /opt/oracle && \
    cd /opt/oracle && \
    curl -o instantclient-basic-linux.x64-19.8.0.0.0dbru.zip https://download.oracle.com/otn_software/linux/instantclient/19800/instantclient-basic-linux.x64-19.8.0.0.0dbru.zip && \
    curl -o instantclient-sdk-linux.x64-19.8.0.0.0dbru.zip https://download.oracle.com/otn_software/linux/instantclient/19800/instantclient-sdk-linux.x64-19.8.0.0.0dbru.zip && \
    unzip instantclient-basic-linux.x64-19.8.0.0.0dbru.zip && \
    unzip instantclient-sdk-linux.x64-19.8.0.0.0dbru.zip && \
    rm -f instantclient-basic-linux.x64-19.8.0.0.0dbru.zip instantclient-sdk-linux.x64-19.8.0.0.0dbru.zip && \
    echo /opt/oracle/instantclient_19_8 > /etc/ld.so.conf.d/oracle-instantclient.conf && \
    ldconfig

RUN pecl install oci8-2.2.0 && \
    docker-php-ext-enable oci8

WORKDIR /var/www/html

This Dockerfile will create a new container based on the official PHP 7.4 image, install the Oracle Instant Client and OCI8 extension, and set the working directory to /var/www/html.

  1. Build the Docker image by running the following command in the terminal:
docker build -t my-php-app .

This will create a new Docker image called my-php-app based on the Dockerfile in the current directory.

  1. Run the Docker container by running the following command in the terminal:
docker run -it --rm -v $(pwd):/var/www/html my-php-app

This will start a new container based on the my-php-app image, mount the current directory as the document root, and open an interactive terminal session.

  1. Test the OCI8 extension by running the following command in the terminal:
php -r 'var_dump(extension_loaded("oci8"));'

This should output bool(true) if the extension is installed and loaded correctly.

You can now develop your application inside the Docker container and connect to the Oracle database using the OCI8 extension.

Note: This workaround is not ideal and may have some performance overhead due to running inside a container. It is recommended to switch back to Valet once the OCI8 extension is compatible with PHP 8.1 and 8.2 on Apple Silicon.

1 like
toby's avatar
Level 31

@aurawindsurfing Herd got my attention as well and I'd love to use it... please let us know if you came up with a viable solution. Thanks in advance!

Please or to participate in this conversation.