Download the PHP package php-guard/curl without Composer

On this page you can find all versions of the php package php-guard/curl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package curl

curl

Build Status Scrutinizer Code Quality Code Coverage GPL Licence

This library is an alternative to "https://github.com/php-curl-class/php-curl-class". Easy use with CurlRequest and CurlResponse objects.

Installation

Install via Composer

$ composer require php-guard/curl

Requirements

Usage

Quick Start
require __DIR__ . '/vendor/autoload.php';

use \PhpGuard\Curl\Curl;
use \PhpGuard\Curl\CurlError;

$this->curl  =  new  Curl();

try {
    // Execute a single request
    $response = $this->curl->get('http://example.com'); // Return a CurlResponse
    echo $response->raw();

    // Execute multiple requests
    $responses = $this->curl->multi() // Create a MultiCurl object
        ->get('http://example.com')   // Add a get request
        ->post('http://example.com')  // Add a post request
        ->execute();                  // Return an array of CurlResponse

    foreach ($responses as $response) {
        echo $response->raw();
    }
} catch (CurlError $e) {
    echo 'Error: ' . $curl->getCode(). ': ' . $curl->getMessage(). "\n";
}
Available Methods

\PhpGuard\Curl\Curl

HTTP methods

get(string $url, $query = null, array $headers = []): CurlResponse
post(string $url, $data = null, $query = null, array $headers = []): CurlResponse
put(string $url, $data = null, $query = null, array $headers = []): CurlResponse
patch(string $url, $data = null, $query = null, array $headers = []): CurlResponse
delete(string $url, $data = null, $query = null, array $headers = []): CurlResponse

Run a single request

execute(CurlRequest  $request): CurlResponse

Prepare multiple requests

multi(array  $options  = []): MultiCurl

Edit request and response processing (advanced usage)

getCurlRequestFactory(): CurlRequestFactory
getRequestModifierPipeline(): RequestModifierPipeline

\PhpGuard\Curl\CurlRequest

You can use Curl to execute requests or you can use the CurlRequestFactory to return CurlRequest instances.

Properties url, method and data have getters and setters.

The method setHeaderContentType(string $contentType) is a shortcut for

$curlRequest->getHeaders['Content-Type'] = $contentType

Other methods

execute(bool $throwExceptionOnHttpError = false): CurlResponse
getCurlOptions(): CurlOptions
getHeaders(): Headers

\PhpGuard\Curl\MultiCurl

get(string $url, $query = null, array $headers = []): self
post(string $url, $data = null, $query = null, array $headers = []): self
put(string $url, $data = null, $query = null, array $headers = []): self
patch(string $url, $data = null, $query = null, array $headers = []): self
delete(string $url, $data = null, $query = null, array $headers = []): self
execute(): CurlResponse[]

\PhpGuard\Curl\CurlResponse

statusCode(): int
isError(): bool // True if status code >= 300
headers(): Headers
raw() // Raw content of the response
json() // Array or false if not a json response

\PhpGuard\Curl\CurlRequestFactory

Set the base url for all requests

 setBaseUrl(?string $baseUrl): self

Set the option curl CURLOPT_SSL_VERIFYPEER

 setSslVerifyPeer(bool $value): self

Create a CurlRequest

 create(string $method, string $url, $data = null, $query = null, array $headers = []): CurlRequest

Edit other default curl options

 getDefaultCurlOptions(): CurlOptions
 getDefaultHeaders(): Headers

\PhpGuard\Curl\Collection\CurlOptions

This class implements \ArrayAccess. It can therefore be used as an array.

\PhpGuard\Curl\Collection\Headers

This class implements \ArrayAccess. It can therefore be used as an array.

In addition, the keys are case insensitive.

\PhpGuard\Curl\RequestModifierPipeline

Add an object to modify CURL requests

pipe(RequestModifierInterface $requestModifier): self

By default, FileRequestModifier and PlainTextRequestModifier are active. If necessary, you can add an instance of ProxyRequestModifier


All versions of curl with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
ext-curl Version *
ext-json Version *
ext-mbstring Version *
ext-fileinfo Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package php-guard/curl contains the following files

Loading the files please wait ....