Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save syahzul/473ef51b61d82f1f5e294bf5cb804fed to your computer and use it in GitHub Desktop.
Save syahzul/473ef51b61d82f1f5e294bf5cb804fed to your computer and use it in GitHub Desktop.

Revisions

  1. syahzul revised this gist Jun 25, 2024. 1 changed file with 2 additions and 2 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # How to install PHP OCI8 for macOS Ventura/Sonoma on Apple Silicon Macs
    # How to install PHP OCI8 for macOS Ventura/Sonoma on Apple Silicon Macs - outdated

    > **Note** <br>
    > [!CAUTION]
    > Finally Oracle release Instant Client for arm64 architecture. Refer new tutorial [How to install PHP OCI8 for macOS Ventura/Sonoma on Apple Silicon Macs (arm64 version)](https://gist.github.com/syahzul/d61d8ccea7c5959a84ed52d14159d8a9) here.
    > **Note** <br>
  2. syahzul revised this gist Jun 25, 2024. 1 changed file with 3 additions and 2 deletions.
    Original file line number Diff line number Diff line change
    @@ -148,5 +148,6 @@ if (function_exists('oci_connect')) {
    ```

    ## References
    1. [How to install OCI8 on macOS (Monterey) M1 Processor with PHP 8.1](https://gist.github.com/syahzul/adfac83e1d930f400855b5425564dfda)
    2. [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)
    1. [How to install PHP OCI8 for macOS Ventura/Sonoma on Apple Silicon Macs (arm64 version)](https://gist.github.com/syahzul/d61d8ccea7c5959a84ed52d14159d8a9)
    2. [How to install OCI8 on macOS (Monterey) M1 Processor with PHP 8.1](https://gist.github.com/syahzul/adfac83e1d930f400855b5425564dfda)
    3. [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)
  3. syahzul revised this gist Jun 25, 2024. 1 changed file with 3 additions and 0 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    # How to install PHP OCI8 for macOS Ventura/Sonoma on Apple Silicon Macs

    > **Note** <br>
    > Finally Oracle release Instant Client for arm64 architecture. Refer new tutorial [How to install PHP OCI8 for macOS Ventura/Sonoma on Apple Silicon Macs (arm64 version)](https://gist.github.com/syahzul/d61d8ccea7c5959a84ed52d14159d8a9) here.
    > **Note** <br>
    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)

  4. syahzul revised this gist Feb 17, 2024. 1 changed file with 16 additions and 9 deletions.
    Original file line number Diff line number Diff line change
    @@ -72,16 +72,22 @@ 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)
    Download the following files from [Oracle Instant Client Downloads for macOS (Intel x86)](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)
    - [Basic Package (ZIP)](https://download.oracle.com/otn_software/mac/instantclient/1916000/instantclient-basic-macos.x64-19.16.0.0.0dbru.dmg)
    - [SDK Package (ZIP)](https://download.oracle.com/otn_software/mac/instantclient/1916000/instantclient-sdk-macos.x64-19.16.0.0.0dbru.dmg)

    Unzip and move it to the `/opt/oracle/instantclient_19_8`.
    Create a folder for the files.

    ```bash
    sudo mkdir -p /opt/oracle/instantclient
    ```

    Now, extract the .dmg files and move the contents to `/opt/oracle/instantclient`.

    ## 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.
    Wen can proceed to install the latest version of PHP (which is 8.3 at the moment) and the dependencies. It may take a while to complete.

    ```bash
    brew install php
    @@ -91,16 +97,17 @@ Verify the PHP version installed on our machine.
    ```bash
    php -v

    PHP 8.2.10 (cli) (built: Aug 29 2023 15:31:38) (NTS)
    PHP 8.3.3 (cli) (built: Feb 13 2024 15:41:14) (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
    Zend Engine v4.3.3, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.3, Copyright (c), by Zend Technologies
    ```

    ## Install PHP OCI8

    Install the latest version of oci8 (v3.3.0) with PECL.
    ```bash
    echo instantclient,/opt/oracle/instantclient_19_8 | pecl install oci8
    echo instantclient,/opt/oracle/instantclient | pecl install oci8
    ```
    **Note:**

  5. syahzul revised this gist Feb 17, 2024. 1 changed file with 12 additions and 0 deletions.
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,18 @@ If your using macOS Monterey or below, please refer to [How to install OCI8 on m

    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.

    ## Install Rosetta

    In Terminal, there is no automatic detection for missing Rosetta to run older architecture command line tools.

    If you haven't been prompted for any other app already, manually install [Rosetta 2](https://support.apple.com/en-gb/HT211861):

    ```bash
    softwareupdate --install-rosetta
    ```

    ## Shortcut to switch architecture

    Open the Terminal and run the following codes to add aliases to switch between architecture.

    ```bash
  6. syahzul revised this gist Sep 27, 2023. 1 changed file with 8 additions and 4 deletions.
    Original file line number Diff line number Diff line change
    @@ -95,14 +95,18 @@ echo instantclient,/opt/oracle/instantclient_19_8 | pecl install oci8
    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
    ## Allows Instant Client files run on macOS

    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:
    By default, macOS will block the Instant Client files since the developer cannot be verified. We have to allow it one by one.

    Open your `System Settings` > `Privacy & Security` > `Security`, and keep it open, don't close it.

    Run the command below to trigger the warning.
    ```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.
    macOS will pop up the warning dialog, 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
    @@ -121,6 +125,6 @@ if (function_exists('oci_connect')) {
    }
    ```

    References:
    ## References
    1. [How to install OCI8 on macOS (Monterey) M1 Processor with PHP 8.1](https://gist.github.com/syahzul/adfac83e1d930f400855b5425564dfda)
    2. [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)
  7. syahzul revised this gist Sep 27, 2023. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -95,7 +95,7 @@ echo instantclient,/opt/oracle/instantclient_19_8 | pecl install oci8
    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
    ## 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
  8. syahzul revised this gist Sep 27, 2023. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -86,7 +86,7 @@ Zend Engine v4.2.10, Copyright (c) Zend Technologies
    ```

    ## Install PHP OCI8
    Install the latest version of oci8 (v3.2.1) with PECL.
    Install the latest version of oci8 (v3.3.0) with PECL.
    ```bash
    echo instantclient,/opt/oracle/instantclient_19_8 | pecl install oci8
    ```
  9. syahzul revised this gist Sep 27, 2023. No changes.
  10. syahzul revised this gist Sep 27, 2023. 1 changed file with 0 additions and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -124,4 +124,3 @@ if (function_exists('oci_connect')) {
    References:
    1. [How to install OCI8 on macOS (Monterey) M1 Processor with PHP 8.1](https://gist.github.com/syahzul/adfac83e1d930f400855b5425564dfda)
    2. [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)
    <sup>[1]</sup> [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)
  11. syahzul revised this gist Sep 27, 2023. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ If your using macOS Monterey or below, please refer to [How to install OCI8 on m

    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.<sup>[1]</sup>
    Open the Terminal and run the following codes to add aliases to switch between architecture.

    ```bash
    echo "alias intel='env /usr/bin/arch -x86_64 /bin/zsh --login'" >> ~/.zshrc
  12. syahzul revised this gist Sep 27, 2023. 1 changed file with 3 additions and 0 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    # How to install PHP OCI8 for macOS Ventura/Sonoma on Apple Silicon Macs

    > **Note** <br>
    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.<sup>[1]</sup>
  13. syahzul renamed this gist Sep 27, 2023. 1 changed file with 1 addition and 0 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    # How to install PHP OCI8 for macOS Ventura/Sonoma on Apple Silicon Macs

    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.

  14. syahzul renamed this gist Sep 27, 2023. 1 changed file with 0 additions and 0 deletions.
  15. syahzul created this gist Sep 27, 2023.
    123 changes: 123 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,123 @@

    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.<sup>[1]</sup>

    ```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
    <?php
    if (function_exists('oci_connect')) {
    echo 'OCI8 is working!';
    } else {
    echo 'Whoopss...not working!';
    }
    ```

    References:
    1. [How to install OCI8 on macOS (Monterey) M1 Processor with PHP 8.1](https://gist.github.com/syahzul/adfac83e1d930f400855b5425564dfda)
    2. [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)
    <sup>[1]</sup> [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)