Download the PHP package phly/http without Composer

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

phly/http

Abandoned! Or, rather, rebranded!

phly/http has moved to the zendframework organization as zend-diactoros (Diactoros, literally "the messenger," an epithet for Hermes).

Please use that package instead, and contribute issues and pull requests against it I have closed issues and pull requests against phly/http at this time.

Scrutinizer Code Quality Code Coverage Scrutinizer Build Status

phly/http is a PHP package containing implementations of the accepted PSR-7 HTTP message interfaces, as well as a "server" implementation similar to node's http.Server.

This package exists:

Installation and Requirements

Install this library using composer:

phly/http has the following dependencies (which are managed by Composer):

Usage

Usage will differ based on whether you are writing an HTTP client, or a server-side application.

For HTTP client purposes, you will create and populate a Request instance, and the client should return a Response instance.

For server-side applications, you will create a ServerRequest instance, and populate and return a Response instance.

HTTP Clients

A client will send a request, and return a response. As a developer, you will create and populate the request, and then introspect the response. Both requests and responses are immutable; if you make changes -- e.g., by calling setter methods -- you must capture the return value, as it is a new instance.

(Note: phly/http does NOT ship with a client implementation; the above is just an illustration of a possible implementation.)

Server-Side Applications

Server-side applications will need to marshal the incoming request based on superglobals, and will then populate and send a response.

Marshaling an incoming request

PHP contains a plethora of information about the incoming request, and keeps that information in a variety of locations. Phly\Http\ServerRequestFactory::fromGlobals() can simplify marshaling that information into a request instance.

You can call the factory method with or without the following arguments, in the following order:

The method will then return a Phly\Http\ServerRequest instance. If any argument is omitted, the associated superglobal will be used.

Manipulating the response

Use the response object to add headers and provide content for the response. Writing to the body does not create a state change in the response, so it can be done without capturing the return value. Manipulating headers does, however.

"Serving" an application

Phly\Http\Server mimics a portion of the API of node's http.Server class. It invokes a callback, passing it an ServerRequest, an Response, and optionally a callback to use for incomplete/unhandled requests.

You can create a server in one of three ways:

Server callbacks can expect up to three arguments, in the following order:

Once you have your server instance, you must instruct it to listen:

At this time, you can optionally provide a callback to listen(); this will be passed to the handler as the third argument ($done):

Typically, the listen callback will be an error handler, and can expect to receive the request, response, and error as its arguments (though the error may be null).

API

Request Message

Phly\Http\Request implements Psr\Http\Message\RequestInterface, and is intended for client-side requests. It includes the following methods:

Requests are immutable. Any methods that would change state -- those prefixed with with and without -- all return a new instance with the changes requested.

ServerRequest Message

For server-side applications, Phly\Http\ServerRequest implements Psr\Http\Message\ServerRequestInterface, which provides access to the elements of an HTTP request, as well as uniform access to the various elements of incoming data. The methods included are:

The ServerRequest is immutable. Any methods that would change state -- those prefixed with with and without -- all return a new instance with the changes requested. Server parameters are considered completely immutable, however, as they cannot be recalculated, and, rather, is a source for other values.

Response Message

Phly\Http\Response provides an implementation of Psr\Http\Message\ResponseInterface, an object to be used to aggregate response information for both HTTP clients and server-side applications, including headers and message body content. It includes the following:

Like the Request and ServerRequest, responses are immutable. Any methods that would change state -- those prefixed with with and without -- all return a new instance with the changes requested.

ServerRequestFactory

This static class can be used to marshal a ServerRequest instance from the PHP environment. The primary entry point is Phly\Http\ServerRequestFactory::fromGlobals(array $server, array $query, array $body, array $cookies, array $files). This method will create a new ServerRequest instance with the data provided. Examples of usage are:

URI

Phly\Http\Uri is an implementation of Psr\Http\Message\UriInterface, and models and validates URIs. It implements __toString(), allowing it to be represented as a string and echo()'d directly. The following methods are pertinent:

Like the various message objects, URIs are immutable. Any methods that would change state -- those prefixed with with and without -- all return a new instance with the changes requested.

Stream

Phly\Http\Stream is an implementation of Psr\Http\Message\StreamInterface, and provides a number of facilities around manipulating the composed PHP stream resource. The constructor accepts a stream, which may be either:

If a stream identifier is provided, an optional second parameter may be provided, the file mode by which to fopen the stream.

ServerRequest objects by default use a php://input stream set to read-only; Response objects by default use a php://memory with a mode of wb+, allowing binary read/write access.

In most cases, you will not interact with the Stream object directly.

UploadedFile

Phly\Http\UploadedFile is an implementation of Psr\Http\Message\UploadedFileInterface, and provides abstraction around a single uploaded file, including behavior for interacting with it as a stream or moving it to a filesystem location.

In most cases, you will only use the methods defined in the UploadedFileInterface.

Server

Phly\Http\Server represents a server capable of executing a callback. It has four methods:

You can create an instance of the Server using any of the constructor, createServer(), or createServerFromRequest() methods. If you wish to use the default request and response implementations, createServer($middleware, $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES) is the recommended option, as this method will also marshal the ServerRequest object based on the PHP request environment. If you wish to use your own implementations, pass them to the constructor or createServerFromRequest() method (the latter will create a default Response instance if you omit it).

listen() executes the callback. If a $finalHandler is provided, it will be passed as the third argument to the $callback registered with the server.

Emitting responses

If you are using a non-SAPI PHP implementation and wish to use the Server class, or if you do not want to use the Server implementation but want to emit a response, this package provides an interface, Phly\Http\Response\EmitterInterface, defining a method emit() for emitting the response. A single implementation is currently available, Phly\Http\Response\SapiEmitter, which will use the native PHP functions header() and echo in order to emit the response. If you are using a non-SAPI implementation, you will need to create your own EmitterInterface implementation.

Serialization

At times, it's useful to either create a string representation of a message (serialization), or to cast a string or stream message to an object (deserialization). This package provides features for this in Phly\Http\Request\Serializer and Phly\Http\Response\Serializer; each provides the following static methods:

The deserialization methods (from*()) will raise exceptions if errors occur while parsing the message. The serialization methods (toString()) will raise exceptions if required data for serialization is not present in the message instance.


All versions of http with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.8
psr/http-message Version ~1.0
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 phly/http contains the following files

Loading the files please wait ....