jump to navigation

How To Enable the cURL Extension on XAMP / WAMP (Windows) March 4, 2012

Posted by Tournas Dimitrios in PHP.

cURL , a free and easy-to-use client-side URL transfer library , supports almost all common Internet protocols : http , https , Ftp , Ldap , Imap , POP , SCP , Smtp , Telnet …… Since curl uses libcurl ,   a reliable and portable library which provides you with an easy interface to a range  protocols ,   curl supports the same Internet protocols that libcurl does .  Some examples where cURL could be used are : uploading/downloading files , querying/updating social media websites (Twitter , Facebook ) , interconnecting with a plethora of web-services (Google-Calnedar , Google-Documents …. ) ,  sending Mail from a different Mail-server , …… And not to forget that  behind this excellent tool is Daniel Stenberg , project leader and main developer .

As you may know, PHP has no native support for multithreading like Java, but using the cURL extension makes multithreading possible in PHP.

Almost all web-hosts have this extension enabled (cURL) , so there shouldn’t be problem to implement many of its functionality . A good practice is to test our web-applications on a local development environment before releasing the code to a live server . Though , this extension isn’t enabled by default on Wamp / Xamp , so a few steps must be done prior cURL can be used on our local  environment  .

  • Open a browser and visit a phpinfo()  page , locate the “Loaded Configuration File” directive . It will point the path of PHP’s central configuration file . A common path could be : C:\xampp\php\php.ini
  • Open php.ini , as located from previous step , with your favorite editor .
  • Un-comment the directive  “extension=php_curl.dll” by removing the  ;  (semicolon) from the beginning of the line
  • Copy the following dll’s  from your PHP installation directory into C:/windows/System32 folder
    ssleay32.dll  —   libeay32.dll   — php_curl.dll
  • Restart your Wamp / Xamp server .

Paste the following code into a PHP-file and access it via your browser . It should display Google’s home page  :

//Initializes a new session and return a cURL handle for use with the curl_setopt(), curl_exec() and curl_close() functions
$curl = curl_init() ;

//Sets an option on the given cURL session handle like url, timeout, return transfer
curl_setopt($curl, CURLOPT_URL, "http://scholar.google.gr/schhp?hl=el");
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

// Execute the given cURL session (get the content of the url and put it into the output variable)
$output = curl_exec($curl);

// Outputs the result
echo $output;

// Print the curl info like http response code, content type etc.
echo "<pre>";
 print_r (curl_getinfo($curl));
 echo "</pre>";

// close the curl handle to free system resources
curl_close($curl) ;

Read also :


1. web - March 7, 2012

Hello i am kavin, its my first occasion to commenting anyplace, when
i read this piece of writing i thought i could also create comment due to this good post.

tournasdimitrios1 - March 7, 2012

Welcome and thanks for commenting .

2. online - March 7, 2012

I am genuinely thankful to the holder of this web page who has shared this fantastic article at here.

3. Kenold - May 24, 2013

Thanks. This solved my issue on WAMP server. This is required for the “Video Thumbnails” WordPress plugin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s