Home >Backend Development >PHP Tutorial >How to install PHP with OCIn Laragon

How to install PHP with OCIn Laragon

Patricia Arquette
Patricia ArquetteOriginal
2024-12-26 19:14:10158browse

How to install PHP  with OCIn Laragon

In this tutorial, we’ll walk through the steps to install and configure the OCI8 extension on Laragon with PHP 8.3. The OCI8 extension allows PHP to connect to Oracle databases, and setting it up can be a bit tricky.

1. Download Oracle Instant Client

To use the OCI8 extension, you need to download the Oracle Instant Client. Go to the Oracle Instant Client for Windows x64 downloads page and get the following:

  • instantclient-basic-windows.x64-23.6.0.24.10.zip
  • instantclient-sdk-windows.x64-23.6.0.24.10.zip

Once the downloads are completed, extract both files and move the contents to C:oracleinstantclient_23_6.

2. Add Environment Variable

To make the Oracle Instant Client accessible system-wide, we need to register the Instant Client path to our system.

  • Search for Edit the system environment variables and then click on the Environment Variables button.
  • In the System variables section, click on Path and edit.
  • Add a new value, C:oracleinstantclient_23_6, and click OK.

You can close all the windows now.

For the changes to take effect, restart your computer.

3. Download PHP 8.3

By default, Laragon shipped with PHP 8.1 only, but we can add other PHP versions easily.

Head to PHP for Windows and get your preferred version. In this tutorial, we will download the following:

  • PHP 8.3 VS16 x64 Thread Safe.

Once the download is complete, extract the file on your computer. Then, move the folder php-8.3.14-Win32-vs16-x64 to C:laragonbinphpphp-8.3.14-Win32-vs16-x64.

4. Upgrade Apache for PHP 8.3 Compatibility

Now we need to upgrade Apache bundled with Laragon to the latest version to prevent the httpd.exe - Entry Point Not Found error.

Visit Apache Lounge and download the latest version of Apache, at the time of writing, the latest version is httpd-2.4.62-240904-win64-VS17.

Once downloaded, extract the file and move all files and folders inside this httpd-2.4.62-240904-win64-VS17Apache24 folder to the parent folder httpd-2.4.62-240904-win64-VS17.

We can safely delete the Apache24 folder.

5. Configure Laragon

Open the Laragon application to change the Apache and enable OCI8 extension. Stop all services first, just to be safe.

Apache

Select the new Apache version using the menu Apache > Version > httpd-2.4.62-240904-win64-VS17.

OCI8 extension

Enable OCI8 extension by using the menu PHP > Extensions > oci8_19.

Now we can start all services and test.

6. Test

To verify that OCI8 is installed and working, create a new blank project in Laragon by using Quickapp > Blank.

Create a new file inside this project and add the following codes:

<?php

if (function_exists('oci_connect')) {
    echo "OCI is installed";
} else {
    echo "OCI is not installed";
}

Run the project in your web browser and you should see OCI is installed.

Congratulations! You’ve successfully installed and configured the OCI8 extension on Laragon with PHP 8.3. You can now connect your PHP applications to Oracle databases.

If you encounter any issues, double-check the steps above or consult the official documentation for further assistance.

Happy coding! ?

The above is the detailed content of How to install PHP with OCIn Laragon. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn