Download the PHP package carstenwindler/http-helper without Composer

On this page you can find all versions of the php package carstenwindler/http-helper. 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 http-helper

Http Helper

Latest Stable Version Minimum PHP Version License Total Downloads Scrutinizer Code Quality

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

Supports

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

Here are some http-helper functions in action:

Basic usage

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

Request

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

request_to_string()

Serializes the request object in plain HTTP format according to RFC 7230.

request_to_file()

Just like _request_tostring(), 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.

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

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

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

response_to_string()

Serializes the response object in plain HTTP format according to RFC 7230.

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

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

Advanced usage example

But why would you do that? Here, PhpStorm comes into play. It now comes equipped with the cool 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

The serialization of the PSR-7 requests and responses are done using Laminas Diactoros. Weird name, great library!

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

Todo


All versions of http-helper with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
laminas/laminas-diactoros Version ^3
symfony/http-foundation Version ^7
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 carstenwindler/http-helper contains the following files

Loading the files please wait ...