PHPackages                             calderawp/http - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. calderawp/http

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

calderawp/http
==============

A boilerplate for new composer based PHP projects.

0.2.0(7y ago)0341GPL-2.0PHPPHP ^7.2

Since Jan 9Pushed 7y ago2 watchersCompare

[ Source](https://github.com/CalderaWP/http)[ Packagist](https://packagist.org/packages/calderawp/http)[ RSS](/packages/calderawp-http/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

Caldera Http
============

[](#caldera-http)

Provides objects describing HTTP requests and responses as well as the ability to send HTTP requests. The request and response classes are extended by the rest-api package, which uses them to represent incoming REST API requests and responses.

👀🌋 This Is A Module Of The [Caldera Framework](https://github.com/CalderaWP/caldera)
------------------------------------------------------------------------------------

[](#-this-is-a-module-of-the-caldera-framework)

- 🌋 Find Caldera Forms Here:

    - [Caldera Forms on Github](http://github.com/calderawp/caldera-forms/)
    - [CalderaForms.com](http://calderaforms.com)
- 🌋 [Issues](https://github.com/CalderaWP/caldera/issues) and [pull requests](https://github.com/CalderaWP/caldera/pulls), should be submitted to the [main Caldera repo](https://github.com/CalderaWP/caldera/pulls).

Overview
--------

[](#overview)

Request and response have the following public APIs

Request Only:

- `getParam($name)` - Get the value of a request body (or query argument) field.
- `getParams()` - Get the values of all request body (or query argument) fields.
- `setParam($name,$value)` - Set the value of a request or response body (or query argument) field.

Response Only:

- `getData()` - Get the values of all request body (or query argument) fields.
- `getStatus()` - Set the request HTTP method.
- `getStatus($code)` - Set the HTTP status method.

Request and Response

- `getHeader($name)` - Get the value of a request or response header.
- `getHeaders()` - Get the values of a all request or response headers.
- `setHeader($name,$value)` - Set the name of a request or response header.
- `getHttpMethod` - Get the request HTTP method.
- `setHttpMethod` - Set the request HTTP method.

Usage
-----

[](#usage)

Main module class methods:

- `send()` - Send an HTTP request to the specified URL.
    - Supply a `Request` object and a URL. The response will be returned, represented by a `Response` object.
    - Uses Guzzle by default.
- `setClient()` Reset the HTTP client.
    - Useful for testing. There is an example in [the phpunit cheatsheat](/docs/cheetsheets-and-links/cheatsheat-phpunit.md)
    - Could be used to add a different HTTP transport or something that pretends to be HTTP.

There are other public methods. They really should get moved to another class, as this class. Don't use them please.

### Install

[](#install)

- Add to your package:
    - `composer require calderawp/http`
- Install for development:
    - `git clone git@github.com:CalderaWP/http.git && composer install`

### Using

[](#using)

- Access from main container:

```
$http = \caldera()->getHttp();
```

- Reset Client

```
        use GuzzleHttp\Handler\MockHandler;
        use GuzzleHttp\HandlerStack;
        use GuzzleHttp\Psr7\Response;

        //...

        $mockResponse = new Response(200, ['X-HELLO' => 'ROY'],
			json_encode(['messageFromServer' => 'Everything Is An Illusion.']));
		$mock = new MockHandler([
			$mockResponse,
		]);
		$handler = HandlerStack::create($mock);
		$client = new Client(['handler' => $handler]);
		\caldera()->getHttp()->setClient($client);
```

### Making A Remote HTTP Request

[](#making-a-remote-http-request)

All HTTP requests are represented by the objects of the `Request` class and then passed to `CalderaHttp::send()`

- Create An Request Object First, you need to create a request object:

```
$apiRequest = new \calderawp\caldera\Http\Request();
$apiRequest->setHttpMethod('POST'); //how to dispatch
$apiRequest->setParams([ 'stateOfMind' => 'Super Chill' ); //Request body
$apiRequest->setHeaders([ 'X-CONTENT-TYPE' => 'application/json' ] ); //Request headers
```

- Dispatch Request Object Then you can dispatch your request. If the request is invalid and exception may be thrown -- by CalderaHttp or Guzzle. A generic catch is recommenced:

```
try {
    $response = \caldera()
        ->getHttp()
        ->send($apiRequest, $url);
} catch (\Exception $e) {
    throw  $e;
}
```

- Using The Response

```
$status = $response->getHeaders(); //All headers returned by remote API
$status = $response->getStatus(); //status code returned
$body = $response->getData();// body of remote request response
```

Testing
-------

[](#testing)

- Run all tests (JK, just unit tests because that's the pattern)
    - `composer test`
- Run unit tests
    - `composer test:unit`
- Run acceptance tests
    - `composer test:acceptance`

License, Copyright, etc.
------------------------

[](#license-copyright-etc)

Copyright 2018+ CalderaWP LLC and licensed under the terms of the GNU GPL license. Please share with your neighbor.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

2681d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca938daf3f2a666cd32c7bdb6e30714da6fe0e6cd5012fe4864b18afae43fbcd?d=identicon)[Shelob9](/maintainers/Shelob9)

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/calderawp-http/health.svg)

```
[![Health](https://phpackages.com/badges/calderawp-http/health.svg)](https://phpackages.com/packages/calderawp-http)
```

###  Alternatives

[matthiasnoback/php-ast-inspector

71180.6k](/packages/matthiasnoback-php-ast-inspector)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
