- Homebrew
- Command Line Tools for Xcode
- PHP 7.3 or 7.4 via Homebrew
Create a folder to store Oracle Instant Client files.
sudo mkdir /opt/oracle
Download the following files from Oracle website
Unzip all theses files into a the directory /opt/oracle/instantclient_19_8
.
ln -s /opt/oracle/instantclient_19_8/sdk/include/*.h /usr/local/include/
ln -s /opt/oracle/instantclient_19_8/*.dylib /usr/local/lib/
ln -s /opt/oracle/instantclient_19_8/*.dylib.19.1 /usr/local/lib/
ln -s /usr/local/lib/libclntsh.dylib.19.1 /usr/local/lib/libclntsh.dylib
pecl install oci8-2.2.0
If the script prompt you to provide the path to ORACLE_HOME directory, respond with:
instantclient,/opt/oracle/instantclient_19_8
Note:
If you ever got error command not found: pecl
, make sure PHP bin folder is included in your environment path.
Create a file containing the following codes.
if (function_exists('oci_connect')) {
echo 'OCI8 is working!';
}
else {
echo 'Whoopss...not working!';
}
Restart your HTTP Server and test.
All command executed successfully but getting below error: (On macbook M2)
PHP Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /opt/homebrew/lib/php/pecl/20190902/oci8.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/oci8.so, 0x0009): symbol not found in flat namespace '_OCIAttrGet'), /opt/homebrew/lib/php/pecl/20190902/oci8.so.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/oci8.so.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/oci8.so.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/php/pecl/20190902/oci8.so.so' (no such file), '/opt/homebrew/lib/php/pecl/20190902/oci8.so.so' (no such file))) in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /opt/homebrew/lib/php/pecl/20190902/oci8.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/oci8.so, 0x0009): symbol not found in flat namespace '_OCIAttrGet'), /opt/homebrew/lib/php/pecl/20190902/oci8.so.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/oci8.so.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/oci8.so.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/php/pecl/20190902/oci8.so.so' (no such file), '/opt/homebrew/lib/php/pecl/20190902/oci8.so.so' (no such file))) in Unknown on line 0
PHP 7.4.33 (cli) (built: Jun 17 2023 06:19:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
Checked the location and found oci8.so.
What to do now??