Download the PHP package kambo/httpmessage without Composer

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

kambo httpmessage

Build Status Scrutinizer Code Quality Code Coverage Dependency Status

Standalone complete implementation of PSR-7 - HTTP message interfaces.

Package is not depended on any existing framework and implements only functionality described in PSR-7.

Install

Prefered way to install library is with composer:

Basic usage

Factories

Package comes with the set of factory classes for creating instances of , , and classes from the super global variables (, , etc.). Each of object is created by calling method on corresponding factory. Only parameter is instance of environment class. For example following code will create instance of :

Environment object is simple wrapper around server and CGI variables and is usually instanced from the super global variables (, , etc.).

Constructor of class has two mandatory parameters - and .

Server is an associative array containing information such as headers, paths, and script locations, it must have same structure as the super global variable . Body is , created from raw data from the request body. Usually it should be created from the stream.

Constructor also accept three optional parameters - post, cookie and files. Each of these parameters is counterpart to super global variable and it must have same structure eg.: cookie must have same structure as the variable. If some of these parameters is missing an empty array is used.

Server request - ServerRequest

Server request is representation of an incoming, server-side HTTP request.

Per the HTTP specification, this class includes properties for each of the following:

Additionally, it encapsulates all data as it has arrived to the application from the CGI and/or PHP environment, including:

Creation of instance is done through from existing super global variables ($_POST, $_COOKIE, $_FILES, etc.):

Working with ServerRequest

Getting values

ServerRequest comes with lot of handy methods for working with the request:

One of the most important part of the request its body. Request body can be obtained by calling method :

Package parse raw body of request according the content type of request. Following content type are supported:

Uploaded files are stored as tree of UploadedFile class instances. They can be obtained with method :

Modifying request

Request can be modified by methods that are prefixed by with string. For example:

As the requests are immutable; all methods that change state retain the internal state of the current message and return an instance that contains the changed state.

Stream

Stream provides a wrapper around the most common PHP streams operations, including serialization of the entire stream to a string.

Stream is usually used for describing of or body content.

New instance of Stream must be created from existing :

Content of can be easily converted to string with method :

Request

Request is representation of an outgoing, client-side request. It can for example represent request to some third party website.

Request object is created with method and URI as the parameters:

Request object constructor also accept three additional optional parameters - headers, body and protocol.

Headers are represented by instance of object, following snippet show creating request with header set to value :

Request body can be string or instance of class, if the string is provided an instance of will be created from this string:

Request is immutable; all methods that change state retain the internal state of the instance and return a new instance that contains the changed state.

Note: package do not provide client for performing the actual request.

Response

Response is representation of an outgoing, server-side response. Usually represents data that will be send to a browser.

Constructor of response object has three optional parameters - status, headers and body. If the status is not provided status code 200 ('OK') is used. Default value for the rest of parameters is null.

If you want to include additional headers you can do it in same way as in , by creating and setting instance of class:

Treatment of body is also same as in the case of class, it can be an instance of or string.

Response is immutable; all methods that change state retain the internal state of the instance and return a new instance that contains the changed state.

License

The MIT License (MIT), https://opensource.org/licenses/MIT


All versions of httpmessage with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
psr/http-message 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 kambo/httpmessage contains the following files

Loading the files please wait ....