Download the PHP package ennacx/php-simple-curl without Composer

On this page you can find all versions of the php package ennacx/php-simple-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 php-simple-curl

PHP Simple cURL

PHP Version Require Latest Stable Version Total Downloads Latest Unstable Version License

A small PHP 8.2+ cURL wrapper that builds typed request objects, executes them through single or multi clients, and returns response objects.

Philosophy

PHP's cURL extension is powerful, but its option-based API can become hard to read as requests grow. Additionally, the sheer number of granular cURL constants provided by PHP makes it challenging to select the most appropriate ones.

PHP Simple cURL keeps the core pieces explicit:

The library favors small value objects, immutable options, and predictable response helpers over a large fluent client with hidden state.

Requirements

Installation

Release Candidate Policy

Release Candidate versions are considered API complete.

During the RC phase:

This policy helps ensure that the stable release is a true continuation of the RC series.

💡 Refine, don't redefine.

Core Flow

  1. Create a Request with the HTTP method, URL, and request headers.
  2. Create CurlOptions for timeout, SSL, proxy, auth, redirect, and response capture settings.
  3. Pass the request to SingleClient::send() or MultiClient::sendAll().
  4. Read the returned Response object.

You may pass either a plain Request or the object returned by Request::prepare() to client send*() methods. When a plain Request is passed, the client prepares it internally with default CurlOptions.

Single Request

Multiple Requests

MultiClient::sendAll() executes multiple requests with cURL multi and returns a Responses collection keyed by each request ID.

Request

Request describes the HTTP request itself. It owns the URL, HTTP method, request ID, and request headers. It does not execute cURL and does not own transport options.

Accept Header

Use accept() or accepts() to add an Accept header from common ContentType values, MediaRange values, or custom media type strings.

The third request sends:

Use withQuality() only for values that need an explicit Quality Value. You do not need to add it to every accepted type, and q=1 can usually be omitted because it is the HTTP default.

If the same media type is added more than once, the first value wins. For example:

The request above sends only:

You can still set a fully custom Accept header with headers():

An explicitly provided Accept header is kept and is not overwritten by accept() or accepts().

Header names, header values, and Accept values must not contain line breaks. Invalid header or Accept input throws InvalidRequestException.

Query Parameters

Request can manage GET query parameters separately from the base URL.

Existing query strings are parsed when the request is created:

The request above is executed as:

Use params() to add multiple query parameters:

Passing null removes an existing query parameter when overwriting is enabled:

Use overwrite: false to keep existing values:

URL fragments are preserved and appended after the rebuilt query string:

This is executed as:

Request Body

Request can also hold a request body. The body is converted into CURLOPT_POSTFIELDS when the request is executed.

ContentType represents common HTTP media types. In the current request body API, it is used to choose the default Content-Type header for body() and bodyFromFile().

Use body() when you already have a raw string payload:

Use bodyFromFile() when the request body should be read from a local file:

bodyFromFile() reads the file contents and sends them as the request body. It is useful for APIs that expect raw text, JSON, XML, or binary-like payloads in the body. It is not a multipart file upload helper.

Use json() to encode an array as JSON. The default Content-Type is application/json.

You can also pass a pre-encoded JSON string. The string is validated before it is stored as the request body.

Use form() for application/x-www-form-urlencoded payloads:

When a body helper is used, PHP Simple cURL sets the matching Content-Type automatically unless you explicitly provide one with headers().

Use attach() to send files as multipart/form-data:

When attachments are present, Content-Type is managed by cURL. Any user-defined Content-Type header is removed so cURL can generate the required multipart boundary.

If a multipart field name conflicts with a form field name or another attachment, the attachment overwrites the existing field by default. Pass allowOverwrite: false to attach() to reject duplicate names instead:

Use attachFile() when the default filename and MIME handling are enough:

The multipart field name defaults to the local filename without extension. Pass name when the API expects a specific field name:

Attachments can be combined with form() fields only. JSON or raw body payloads cannot be mixed with file attachments.

Stream-based request bodies are planned for a later implementation. They are intentionally not part of the current public request body API yet.

Supported request factory methods:

Curl Options

CurlOptions describes how cURL should execute the request. It owns timeout, SSL, proxy, auth, redirect, and response capture settings.

CurlOptions is immutable. Fluent helper methods return a new instance, so remember to keep the returned value.

Fluent helpers are also available:

Because options are immutable, this does not change the original instance:

Raw cURL Options

Use RawCurlOptions when you need a CURLOPT_* setting that is not covered by a dedicated config object yet.

The fluent shortcut is also available:

Raw options are applied after generated options and config objects. By default, they can overwrite existing cURL options. Pass overwrite: false to keep generated values and only add missing options.

Raw options are a low-level escape hatch. Pass only trusted values, especially when setting security-sensitive options such as SSL verification, redirects, protocols, or custom headers.

Sending Requests

Clients accept either Request or PreparedRequest.

Use Request::prepare() when you want to attach custom CurlOptions explicitly:

If no custom options are required, pass Request directly. The client converts it to PreparedRequest internally with default CurlOptions.

sendAll() returns a Responses collection. Use get() when the response must exist, or find() when a missing response should return null.

Responses implements ArrayAccess, so you can also read responses with $responses[$request->getId()]. The collection is read-only; write and unset operations throw ImmutableCollectionException. Use filter() when you want a new Responses collection containing only matching responses.

Config Objects

Config objects own their own cURL option mapping. The client passes them through CurlOptionsFactory before execution.

Client

Use client settings to add User-Agent and Referer headers through CurlOptions. Pass only the header value, not a full header line.

If the same headers are explicitly set with Request::headers(), those request headers are kept.

SSL

Proxy

Authentication

AuthConfig::bearer() expects the token only. Do not include Authorization: or the Bearer scheme.

Timeout

Redirects

Response

Both clients return Response objects.

Response status helpers

Header helpers

JSON helper

Exceptions

PHP Simple cURL throws library-specific exceptions for invalid API usage and execution setup failures.

Network-level cURL errors such as connection failures or timeouts are returned as Response::$error and Response::$errorMessage when a response object can be created. They are not thrown by default. Use Response::toCurlError() when you want the raw cURL error code as a CurlError enum.

Exception classes

Security Notes

PHP Simple cURL is designed primarily for HTTP and HTTPS requests, but Request does not currently restrict URL schemes to http and https.

If request URLs are built from external input, validate allowed schemes, hosts, ports, and network ranges in your application before creating a Request. This is especially important to avoid SSRF-style issues or unintended access to local/internal resources.

RawCurlOptions is a low-level escape hatch. Options passed through raw() are applied directly to cURL and may override generated options, including headers, SSL verification, redirects, protocols, and other security-sensitive behavior. Pass only trusted values.

For vulnerability reporting and supported versions, see Security Policy.

Notes

License

MIT


All versions of php-simple-curl with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-curl Version *
ext-openssl 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 ennacx/php-simple-curl contains the following files

Loading the files please wait ...