PHP OCI8 3.4 is available from PECL

Christopher Jones
3 min readJul 25, 2024

--

I’ve just released PHP OCI8 3.4 on PECL. PHP is still active and going strong — and this is reflected in the download numbers for the Oracle Database “OCI8” driver for PHP, which had a 50% growth over the last year.

Photo by Ben Griffiths on Unsplash

PHP OCI8 3.4 is a small iteration with one important change to better support external authentication, e.g with Oracle wallets, when using oci_pconnect(). Other changes allow it to build with PHP 8.2 and PHP 8.3, and for the test suite to run cleanly with the improved database errors messages of Oracle Database 23ai.

Install the new release in PHP 8.2 or 8.3 as a shared extension by executing:

$ pecl install oci8

and, when prompted, specify where to find Oracle Client libraries. On macOS ARM64 with the latest Instant Client in $HOME/Downloads/instantclient_23_3, my install log is like:

$ pecl install oci8 
downloading oci8-3.4.0.tgz ...
Starting to download oci8-3.4.0.tgz (194,647 bytes)
.........................................done: 194,647 bytes
13 source files, building
running: phpize
Configuring for:
PHP Api Version: 20230831
Zend Module Api No: 20230831
Zend Extension Api No: 420230831
Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] : instantclient,/Users/cjones/Downloads/instantclient_23_3

. . .

Build process completed successfully
Installing '/Users/cjones/php/lib/php/extensions/no-debug-non-zts-20230831/oci8.so'
install ok: channel://pecl.php.net/oci8-3.4.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini

(Remember to use an absolute path without environment variables!)

I then typically run php --ini to find the location of the php.ini file, and append extension=oci8.so to that file.

You can now check the driver is available:

$ php --ri oci8

oci8

OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 3.4.0
Oracle Run-time Client Library Version => 23.3.0.23.9
Oracle Compile-time Instant Client Version => 23.3

Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off
oci8.prefetch_lob_size => 0 => 0

Statistics =>
Active Persistent Connections => 0
Active Connections => 0

The OCI8 extension can be built with Oracle Client libraries from Oracle Database 11.2 or later. The Oracle Client libraries are in the free Oracle Instant Client from www.oracle.com/database/technologies/instant-client.html. They are also included in your database installation.

Oracle’s standard cross-version connectivity applies. For example, PHP OCI8 linked with Oracle Client 19c can connect to Oracle Database 11.2 onward. See Oracle’s note Client / Server Interoperability Support Matrix for Different Oracle Versions (ID 207303.1) for details.

PHP OCI8 3.4 also installs on the current PHP 8.4 Alpha release. If you have an older version of PHP, you will need to install an older driver, e.g.:

  • Use pecl install oci8–3.2.1 to install for PHP 8.1.
  • Use pecl install oci8–3.0.1 to install for PHP 8.0.

If you need a reference for using PHP OCI8, check the second half of The Underground PHP and Oracle Manual and, of course, the OCI8 Documentation.

--

--

Christopher Jones

Oracle Database Product Manager for language drivers including Python python-oracledb, Node.js node-oracledb, PHP OCI8 and more! On Mastodon: @cjbj@phpc.social