How to enable cURL in PHP / XAMPP

To enable cURL in PHP / XAMPP, follow these steps:

  1. Open the XAMPP control panel.
  2. Click the "Config" button next to the Apache service.
  3. In the Apache (httpd.conf) configuration file that opens, search for the following line:
  4. #LoadModule rewrite_module modules/mod_rewrite.so
  5. Remove the # character from the beginning of the line to uncomment it. The line should now look like this:
  6. LoadModule rewrite_module modules/mod_rewrite.so

    Watch a course Learn object oriented PHP

  7. Save the httpd.conf file and close it.
  8. In the XAMPP control panel, click the "Restart" button next to the Apache service to restart the Apache server.
  9. Open the PHP (php.ini) configuration file. On Windows, this file is typically located at C:\xampp\php\php.ini.
  10. Search for the following line in the file:
  11. ;extension=curl
  12. Remove the ; character from the beginning of the line to uncomment it. The line should now look like this:
  13. extension=curl
  14. Save the php.ini file and close it.
  15. In the XAMPP control panel, click the "Stop" button next to the Apache service, and then click the "Start" button to restart the Apache server.

cURL should now be enabled in your PHP installation. To test it, create a PHP file with the following code:

<?php

if (function_exists('curl_version')) {
    echo 'cURL is installed and enabled';
} else {
    echo 'cURL is not installed or enabled';
}

Save the file and load it in your web browser. If cURL is enabled, the message "cURL is installed and enabled" should be displayed.