# How to install PHP OCI8 for macOS Ventura/Sonoma on Apple Silicon Macs
> **Note**
If your using macOS Monterey or below, please refer to [How to install OCI8 on macOS (Monterey) M1 Processor with PHP 8.1](https://gist.github.com/syahzul/adfac83e1d930f400855b5425564dfda)
macOS Ventura and above, duplicating and renaming Terminal.app are disabled by Apple. In order to install the OCI8, we need to switch between arm64 and x86_64 architecture.
Open the Terminal and run the following codes to add aliases to switch between architecture.[1]
```bash
echo "alias intel='env /usr/bin/arch -x86_64 /bin/zsh --login'" >> ~/.zshrc
echo "alias arm='env /usr/bin/arch -arm64 /bin/zsh --login'" >> ~/.zshrc
```
Close and re-open the Terminal and run the following command:
```bash
arm
arch
```
Make sure our current architecture is **arm64**.
## Install Command Line Tools for Xcode
Run the command below if you haven't installed it on your machine.
```bash
xcode-select --install
```
## Uninstall Homebrew for Apple Silicon
If you have installed the Homebrew for Apple Silicon previously, remove it. To uninstall, open the Terminal and use the following command:
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
```
## Switch to i386 architecture
Run the following command to switch to i386:
```bash
intel
arch
```
Make sure our current architecture is **i386**.
## Install Homebrew for Intel
Run the following command to start installing Homebrew.
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
After installation completed, verify that we have installed Intel version, not Apple Silicon by using the command below:
```bash
which brew
```
If the output is ```/usr/local/bin/brew```, then it's for Intel.
But if the output is ```/opt/homebrew/bin/brew```, it's for Apple Silicon. You have to start all over again by uninstalling it using the steps above.
## Oracle Instant Client for macOS (Intel x86)
Download the following files from [Oracle website](https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html)
- [Basic Package (ZIP)](https://download.oracle.com/otn_software/mac/instantclient/198000/instantclient-basic-macos.x64-19.8.0.0.0dbru.zip)
- [SDK Package (ZIP)](https://download.oracle.com/otn_software/mac/instantclient/198000/instantclient-sdk-macos.x64-19.8.0.0.0dbru.zip)
Unzip and move it to the `/opt/oracle/instantclient_19_8`.
## Install PHP
Wen can proceed to install the latest version of PHP (which is 8.2 at the moment) and the dependencies. It may take a while to complete.
```bash
brew install php
```
Verify the PHP version installed on our machine.
```bash
php -v
PHP 8.2.10 (cli) (built: Aug 29 2023 15:31:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.10, Copyright (c) Zend Technologies
with Zend OPcache v8.2.10, Copyright (c), by Zend Technologies
```
## Install PHP OCI8
Install the latest version of oci8 (v3.2.1) with PECL.
```bash
echo instantclient,/opt/oracle/instantclient_19_8 | pecl install oci8
```
**Note:**
1. If you ever got an error `command not found: pecl`, make sure PHP bin folder is included in your environment path.
2. Use the appropriate version of oci8 for your PHP. Refer [https://pecl.php.net/package/oci8](https://pecl.php.net/package/oci8) for more info.
# Instant Client files Security & Privacy
By default, macOS will block the Instant Client files since the developer cannot be verified. Open your `System Preferences` > `Privacy & Security` > `Security`, and keep it open, then run the command below:
```bash
php -m
```
macOS will pop up the warning, click on `Open` (if available) or `Cancel`, and click `Allow Anyway` on your `Privacy & Security` window. You might have to do it a few times until no more warning dialog appears.
Run the command to make sure **oci8** is enabled.
```bash
php -m | grep oci8
```
## Test it out
Create a file containing the following codes.
```php
[1] [M1 Mac — How to switch the Terminal between x86_64 and arm64](https://vineethbharadwaj.medium.com/m1-mac-switching-terminal-between-x86-64-and-arm64-e45f324184d9)