PHPackages                             carstenwindler/http-helper - 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. carstenwindler/http-helper

ActiveLibrary

carstenwindler/http-helper
==========================

2.0.2(6y ago)03.8kMITPHPPHP &gt;=7.2CI failing

Since Sep 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/carstenwindler/http-helper)[ Packagist](https://packagist.org/packages/carstenwindler/http-helper)[ Docs](https://github.com/carstenwindler/http-helper)[ RSS](/packages/carstenwindler-http-helper/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)Dependencies (6)Versions (8)Used By (0)

Http Helper
===========

[](#http-helper)

[![Latest Stable Version](https://camo.githubusercontent.com/c2479c1ba5fd12053c38978bae48cfee88495a03a4c4d03354c9219dcb919797/68747470733a2f2f706f7365722e707567782e6f72672f6361727374656e77696e646c65722f687474702d68656c7065722f762f737461626c65)](https://packagist.org/packages/carstenwindler/http-helper)[![Minimum PHP Version](https://camo.githubusercontent.com/07f61062387f00229b476e44e06e8b0a57a21ff23396aff426e408b62527013f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6361727374656e77696e646c65722f687474702d68656c7065722e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/a69dd017dc659fe597835a47c81e4d57c662257e74e00a48d6e1fe57c41fc451/68747470733a2f2f706f7365722e707567782e6f72672f6361727374656e77696e646c65722f687474702d68656c7065722f6c6963656e7365)](https://packagist.org/packages/carstenwindler/http-helper)[![Total Downloads](https://camo.githubusercontent.com/8a7357e50b17d5ad44a619e52bc1cb3dfcf414aa3c35892576a307afdceea67e/68747470733a2f2f706f7365722e707567782e6f72672f6361727374656e77696e646c65722f687474702d68656c7065722f646f776e6c6f616473)](https://packagist.org/packages/carstenwindler/http-helper)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5602ced5d10e8d51adac99fd44c543a43d42f0e84eb4c81214fddc30c8a679a6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6361727374656e77696e646c65722f687474702d68656c7065722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/carstenwindler/http-helper/?branch=master)

A collection of helper functions for your everyday work with http requests and responses.

Supports

- PSR-7 (`Psr\Http\Message\RequestInterface`, `Psr\Http\Message\ResponseInterface`)
- Symfony HttpFoundation (`Symfony\Component\HttpFoundation\Request`, `Symfony\Component\HttpFoundation\Response`)

The main idea of these functions was to provide quick access to the http information during development (e.g. via the debugger console), that's why the functions are not namespaced. *It's not meant to be used in your actual code*! Srsly, it's not.

Example
=======

[](#example)

Here are some http-helper functions in action:

[![Basic usage](https://camo.githubusercontent.com/ec4f3c21103cc150842678a59cd08be338a97bace39576d7ead9fa7264baa19a/687474703a2f2f6d656469612e6361727374656e77696e646c65722e64652f7061636b616765732f687474702d68656c7065722f687474702d68656c7065722d6578616d706c652d62617369632d75736167652e676966 "Basic usage of http-helper")](https://camo.githubusercontent.com/ec4f3c21103cc150842678a59cd08be338a97bace39576d7ead9fa7264baa19a/687474703a2f2f6d656469612e6361727374656e77696e646c65722e64652f7061636b616765732f687474702d68656c7065722f687474702d68656c7065722d6578616d706c652d62617369632d75736167652e676966)

Installation
============

[](#installation)

`composer require --dev carstenwindler/http-helper`

(I suggest to only add these functions as `require-dev`).

The functions are registered using the composer autoload feature, so there is nothing more for you to do.

Helper functions
================

[](#helper-functions)

Request
-------

[](#request)

Both `Psr\Http\Message\RequestInterface` and `Symfony\Component\HttpFoundation\Request` are supported by the following functions.

### request\_to\_string()

[](#request_to_string)

Serializes the request object in plain HTTP format according to [RFC 7230](https://tools.ietf.org/html/rfc7230#page-19).

### request\_to\_file()

[](#request_to_file)

Just like *request\_to\_string()*, but the request string will be stored in a file called `request.http` in your DOCUMENT\_ROOT.

This way you can e.g. easily execute the request using PhpStorms cool [Editor-based Rest Client](https://blog.jetbrains.com/phpstorm/2017/09/editor-based-rest-client/).

If the file already exists and is not empty, the request will be appended.

### request\_to\_curl()

[](#request_to_curl)

Returns the request object as cURL command, so it can be used e.g. on console or import it in Postman easily.

Response
--------

[](#response)

Both `Psr\Http\Message\ResponseInterface` and `Symfony\Component\HttpFoundation\Response` are supported by the following functions.

### response\_to\_string()

[](#response_to_string)

Serializes the response object in plain HTTP format according to [RFC 7230](https://tools.ietf.org/html/rfc7230#page-19).

### response\_to\_file()

[](#response_to_file)

Just like `response_to_string()`, but the response string will be stored in a file called `response.http` in your DOCUMENT\_ROOT.

File usage
==========

[](#file-usage)

The following example shows you how to store requests and responses in files easily.

[![Advanced usage example](https://camo.githubusercontent.com/d7af652692056f15dba8997688a8e2c5181c3aca0f454f367f62d573fb8b4bc4/687474703a2f2f6d656469612e6361727374656e77696e646c65722e64652f7061636b616765732f687474702d68656c7065722f687474702d68656c7065722d6578616d706c652d66696c652d75736167652e676966 "Basic usage of http-helper")](https://camo.githubusercontent.com/d7af652692056f15dba8997688a8e2c5181c3aca0f454f367f62d573fb8b4bc4/687474703a2f2f6d656469612e6361727374656e77696e646c65722e64652f7061636b616765732f687474702d68656c7065722f687474702d68656c7065722d6578616d706c652d66696c652d75736167652e676966)

But why would you do that? Here, PhpStorm comes into play. It now comes equipped with the cool [Editor-based Rest Client](https://blog.jetbrains.com/phpstorm/2017/09/editor-based-rest-client/) (think of it like a very simple Postman without all the fancy gui).

*http-helper* uses the suffix `.http`, which is recognised by PhpStorm, so you will immediately have the possibility to modify and rerun the request in that file. I quite like the idea, since you could add it to your code base, so your fellow devs would have immediate access.

Credits
=======

[](#credits)

The serialization of the PSR-7 requests and responses are done using [Laminas Diactoros](https://github.com/laminas/laminas-diactoros). Weird name, great library!

For Symfony, the build-in serializers are used. Nice.

Todo
====

[](#todo)

- make storage path of `*_to_file()` configurable

###  Health Score

34

↑

LowBetter than 77% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~549 days

Recently: every ~598 days

Total

6

Last Release

409d ago

Major Versions

v0.1 → v1.02018-09-10

v1.0 → 2.0.02019-04-13

PHP version history (4 changes)v0.1PHP ^5.3 | ^7.0

v1.0PHP &gt;=7.1

2.0.0PHP &gt;=7.2

v1.1.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4761678d271eef1bc9fc3478994848dd54b6d77551e3c065b1b730b5badffb90?d=identicon)[carstenwindler](/maintainers/carstenwindler)

---

Top Contributors

[![carstenwindler](https://avatars.githubusercontent.com/u/5927645?v=4)](https://github.com/carstenwindler "carstenwindler (16 commits)")

---

Tags

curldiactoroshelperhttphttpfoundationlaminaspsr-7requestresponsesymfony

###  Code Quality

TestsPHPUnit

Code StyleECS

### Embed Badge

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

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

###  Alternatives

[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k172.9M1.8k](/packages/symfony-security-bundle)[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[laravel/reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.

1.5k9.4M48](/packages/laravel-reverb)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k5](/packages/elgg-elgg)[api-platform/http-cache

API Platform HttpCache component

223.2M7](/packages/api-platform-http-cache)[oxid-esales/graphql-base

OXID eSales GraphQL base module

24101.0k10](/packages/oxid-esales-graphql-base)

PHPackages © 2026

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