Setting up PHP for Oracle Database When working with Oracle databases for the first time, developers may find OCI8's complex procedures challenging. This blog post includes instructions for installing and configuring Oracle Instant Client and the OCI8 extension for PHP, as well as a step-by-step walkthrough for setting up PHP with OCI8. We also go over typical problems you can run into while configuring things and offer troubleshooting advice to help you fix them. You will have a functional PHP-OCI8 environment at the end of this blog, which you can use to create robust and scalable web apps that take advantage of Oracle Database's features.
Three things needed for connecting with oracle database with PHP.
- Instant Client
Those three option should be the same version, same configuration with with each one. Suppose, if our machine has 64bit , then PHP, OCI and instant client should be the same 64Bit system.
Step 1: Download PHP 7.2
Here, things to notice is:
- PHP version 7.2
- TS version
- VC 15
I explain what those words mean. First, TS mean it is thread safe. That mean, this program can multitask or multi threading enabled. Second, VC 15 means, VC15 (Visual Studio 2015 compiler) and include improvements in performance and stability. And we all know that x64 architecture.
Step 2: Download Oracle Instant Client
We need to download three packages from here.
- Basic Package
Though we’ve downloaded the PHP version x64 that’s why we are downloading the x64 version of Instant Client.
Make a directory in C drive and uncompress all the files to this directory.
Add a new Path to System Variable in our computer. And put the directory where is your Instant Client files in the path value.
Create a new system variable: TNS_ADMIN
Point the directory in that value too.
RESTART YOUR COMPUTER
Step 3: Download the actual OCI8 package
You can download the latest version if you want . As we are using PHP version 7.2 select that version and Thread Safe respectably.
Extract that into: YOUR_XAMPP_DIRECTORY/php/ext directory. Enable it by uncommeting
Done! Check your phpinfo , a new OCI8 options are available in here.