Php startup: unable to load dynamic library ‘oci8_12c’

When encountering the error message “unable to load dynamic library ‘oci8_12c'” in PHP, it means that the PHP OCI8 extension is not properly enabled or configured.

The OCI8 extension is used to connect to Oracle databases using PHP. To resolve this issue, follow the steps below:

  1. Make sure Oracle Instant Client is installed on your system. You can download it from the Oracle website: https://www.oracle.com/database/technologies/instant-client.html. Choose the appropriate version for your operating system.
  2. Extract the downloaded archive to a directory on your system. For example, you can extract it to C:\instantclient on Windows.
  3. Set the ORACLE_HOME environment variable to the directory where you extracted the Instant Client. This can be done through the command line or by editing your system’s environment variables.
  4. Make sure the Instant Client directory is added to the system’s PATH environment variable.
  5. Download the correct version of the OCI8 PHP extension from the PECL website: https://pecl.php.net/package/oci8. Make sure to choose the version that matches your PHP installation.
  6. Extract the downloaded archive to a directory of your choice.
  7. Copy the file oci8_12c.dll (or similar) from the extracted OCI8 directory to the PHP extensions directory. This is usually ext/ within the PHP installation directory.
  8. Edit your PHP configuration file (php.ini) and add the following line:
extension=oci8_12c

Make sure to adjust the filename if it differs from oci8_12c.

Save the changes to the php.ini file and restart your web server for the changes to take effect.

You can verify if the OCI8 extension is enabled by creating a PHP file with the following content:

<?php
phpinfo();
?>

Open this file in your web browser and search for OCI8. If the extension is enabled, you should see a section with information about OCI8.

That’s it! After correctly enabling and configuring the OCI8 extension, the error message should no longer appear and you can successfully connect to Oracle databases using PHP.

Leave a comment