Перейти к содержимому

Как установить curl php

  • автор:

Как установить curl php

To use PHP’s cURL support you must also compile PHP —with-curl[=DIR] where DIR is the location of the directory containing the lib and include directories. In the include directory there should be a folder named curl which should contain the easy.h and curl.h files. There should be a file named libcurl.a located in the lib directory.

Note: Note to Win32 Users
In order to enable this module on a Windows environment, libeay32.dll and ssleay32.dll , or, as of OpenSSL 1.1 libcrypto-*.dll and libssl-*.dll , must be present in your PATH . Also libssh2.dll must be present in your PATH . You don’t need libcurl.dll from the cURL site.

User Contributed Notes 21 notes

15 years ago

You may be confused, as I was, by the instructions for installing cURL in php. The instruction «To use PHP’s cURL support you must also compile PHP —with-curl[=DIR]. » was murky to me, since I didn’t compile php when I installed it. I just copied all of the necessary files to the correct folders as described very clearly in the php manual.

I am using Windows XP and Apache with php 5.1.6. In this situation, and it may apply to php versions of 5.0 and later, all one needs to do is remove the «;» from the front of the directive extension=php_curl.dll. You should also check to make certain that libeay32.dll and ssleay32.dll are in your php directory with the other dll’s. This directory should already be in you path, so the instruction to put them in you path is not critical.

You can then run phpinfo() and you should see a heading for curl in the listing.

Succinctly, my installation of cURL consisted of removing the semi-colon in front of the ;extension=php_curl.dll line in php.ini, saving php.ini and restarting Apache. You may wish to try this if you are using php 5.0 and later and are having difficulty understanding the instructions on the cURL installation page at php.net

How do I install the ext-curl extension with PHP 7?

I’ve installed PHP 7 using this repo, but when I try to run composer install , it’s giving this error:

  • [package] requires ext-curl * -> the requested PHP extension curl is missing from your system.

With PHP 5, you can easily install it by running the yum or apt-get install php5-curl command, but I can’t find how to install the PHP 7 equivalent.

How do I install ext-curl for PHP 7?

Stephan Vierkant
asked Nov 18, 2015 at 9:15
Stephan Vierkant Stephan Vierkant
9,764 8 8 gold badges 62 62 silver badges 97 97 bronze badges

install libcurl first ie. yum install libcurl or apt-get install libcurl . After that configure your php 7 with curl ./configure —with-curl and finally make and install

Jan 30, 2016 at 4:33
@Haridarshan Yea okay, but that’s inconvenient
Feb 3, 2016 at 9:04

I’ve build and install php 7 with curl and other extension. You may also need to install devel libraries.

Feb 3, 2016 at 9:16

12 Answers 12

Well I was able to install it by :

sudo apt-get install php-curl 

on my system. This will install a dependency package, which depends on the default php version.

After that restart apache

sudo service apache2 restart 

1,855 2 2 gold badges 19 19 silver badges 30 30 bronze badges
answered Jan 27, 2016 at 10:48
Sabeeh Chaudhry Sabeeh Chaudhry
6,274 1 1 gold badge 16 16 silver badges 8 8 bronze badges
..and restart the service. sudo service apache2 restart
Sep 9, 2016 at 16:11

Only if you are using the apache webserver version. You don’t need to restart apache for the CLI version of course

Sep 24, 2016 at 17:51
similarly gd2, xmlrpc, soap, etc — all small letters suffix worked
Oct 25, 2016 at 15:43
Instead of sudo service apache2 restart, sudo service apache2 reload
May 16, 2017 at 18:40

This actually depends on the packages available in the APT sources. First, update the APT packages using apt-get update . Then type apt-get install php and press tab twice. It will ask for a confirmation to display the whole list like Display all n possibilities? (y or n): where N is the available number of possibilities. Press Y and you’ll get a long list of available packages, out of which you can find the package name that you want. O course, if you have a long list, this will be a little tedious. But still you can narrow it down based on the version.

README

This library provides an object-oriented and dependency free wrapper of the PHP cURL extension.

If you have questions or problems with installation or usage create an Issue.

Installation

In order to install this library via composer run the following command in the console:

composer require curl/curl

Usage examples

A few example for using CURL with get:

$curl = (new Curl\Curl())->get('http://www.example.com/'); if ($curl->isSuccess()) < // do something with response var_dump($curl->response); > // ensure to close the curl connection $curl->close();

Or with params, values will be encoded with PHP_QUERY_RFC1738 :

$curl = (new Curl\Curl())->get('http://www.example.com/search', [ 'q' => 'keyword', ]);

An example using post

$curl = new Curl\Curl(); $curl->post('http://www.example.com/login/', [ 'username' => 'myusername', 'password' => 'mypassword', ]);

An exampling using basic authentication, remove default user agent and working with error handling

$curl = new Curl\Curl(); $curl->setBasicAuthentication('username', 'password'); $curl->setUserAgent(''); $curl->setHeader('X-Requested-With', 'XMLHttpRequest'); $curl->setCookie('key', 'value'); $curl->get('http://www.example.com/'); if ($curl->error) < echo $curl->error_code; > else < echo $curl->response; > var_dump($curl->request_headers); var_dump($curl->response_headers);

SSL verification setup:

$curl = new Curl\Curl(); $curl->setOpt(CURLOPT_RETURNTRANSFER, TRUE); $curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE); $curl->get('https://encrypted.example.com/');

Example access to curl object:

curl_set_opt($curl->curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1'); curl_close($curl->curl);

Example of downloading a file or any other content

$curl = new Curl\Curl(); // open the file where the request response should be written $file_handle = fopen($target_file, 'w+'); // pass it to the curl resource $curl->setOpt(CURLOPT_FILE, $file_handle); // do any type of request $curl->get('https://github.com'); // disable writing to file $curl->setOpt(CURLOPT_FILE, null); // close the file for writing fclose($file_handle);

Testing

In order to test the library:

  1. Create a fork
  2. Clone the fork to your machine
  3. Install the depencies composer install
  4. Build and start the docker image (in tests/server ) docker build . -t curlserver start docker run -p 1234:80 curlserver
  5. Run the unit tests ./vendor/bin/phpunit tests

Как установить cURL с ограничеными правами?

есть хотинг на нем не установлен данный модуль
к пхп ini доступа нету можно ли като через инклуд подлючить если да то каой надо ачять пакет? и что надо подлючять?

94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
Ответы с готовыми решениями:

Как установить возможность запуска программы только с правами администратора?
Здравствуйте. Как выставить права администратора (highestAvailable) на сторонний .exe? Не через.

Как в curl установить начальную позицию чтения
Надо прочитать большой файл не с начала, а с определенной позиции. Как есть ли в curl что-то типа.

Не выходит установить cURL
Здравствуйте. Такая проблема никак не могу установить cURL на VS 2010. Я не понимаю, документация.

Не могу установить cURL
Здравствуйте. Пытаюсь установить moodle на vps хостинге от logol. Moodle требует установки curl Я.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *