Download the PHP package polymorphine/message without Composer

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

Polymorphine/Message

Latest stable release Build status Coverage status PHP version

PSR-7 Http message implementation

Installation with Composer

Basic usage

Public API of base classes in this package is an implementation of PSR-7: HTTP message interfaces and won't be described here. Below you'll find description of object instantiation methods and their parameter formatting specific to this package.

PSR-17 Factories

Not every aspect of created objects can be changed with mutation methods (like in UriInterface), that's where the need for common factory interfaces came from. Packages that want to rely on abstract psr/message interface, and retain control of passing immutable parameters to encapsulated objects from within their classes will depend on PSR-17: HTTP Factories. For interoperability reasons Package includes implementations of these factories.

Direct instantiation

Constructor instantiation for each of the classes described below allows to create fully configured objects, and since some of them contains many encapsulated parameters instantiating such object might be tedious and unreadable. For some, frequently created objects static constructors are provided to pass some predefined parameters.

ServerRequest

The straight forward way is to instantiate ServerRequest from server globals using ServerRequest::fromGlobals() named constructor and optionally overriding its parameters passing array with server, get, post, cookie or files keys:

This will be most typical way to create ServerRequest instance. Because complete ServerRequest contains large amount of data, other methods of instantiation in production application use cases would require much more effort, and they'll be used mostly for testing with only necessary values provided. For example instead overriding server provided data you can fake it entirely by passing filled arrays to factory's constructor:

Or create new instance directly passing various parameters: request method string, UriInterface, StreamInterface body, headers array and parameters with UploadedFileInterface array, protocol version, parsed body, cookie array... etc. Check ServerRequest constructor phpDoc and some of its parameters implementations for more details.

Request & Response

Request can be created with constructor similar to used in ServerRequest, but $params array uses only version and target keys that defaults to 1.1 and string resolved from $uri parameter.

Response comes with several convenient static constructors that create instance preconfigured with status code or specific headers (usually Content-Type). Default constructor parameters are similar to Request constructor where method and Uri were replaced by status code, and reason phrase instead target in params.

Uri, Stream & UploadedFile

Default constructor for Uri requires array of segments, which is not convenient, but static Uri::fromString() method will create instance by parsing supplied string.

Constructor for Stream takes stream resource type, but two static methods will help creating one - either with uri and access mode or with body string to encapsulate.

UploadedFile all constructor parameters can be derived from server's $_FILES superglobal. Actually all, except StreamInterface, could be passed directly. Secondary constructor method - UploadedFile::fromFileArray() - is a convenient way of translating superglobal into class instance creating stream instance in the process.

Note that for multiple files superglobal data structure is populated in somewhat transposed fashion, so extracting it to create multiple instances of UploadedFile requires some iterations over its nested structure. Since these objects will be used mostly as server request property, instances for multiple files are created within ServerData object. You can use this class to create the array of multiple uploaded files from transposed array (normally $_FILES) if you want to do it separately:

UploadedFile for non-SAPI environments

UploadedFileFactory by default creates UploadedFile instance for web server environments, which support $_FILES superglobal and security mechanism that can tell whether given file was really uploaded or not (you cannot simply pick any file in the filesystem and move it somewhere else). In case of other types of http servers (like command line scripts listening for http requests in some event loop), you cannot use move_uploaded_file() function and need to handle this process differently.

Package includes NonSAPIUploadedFile that can move file (stream) in non-SAPI environments, but security part (recognising that file was uploaded) depends on implementation and should be resolved internally (when creating stream). You can create its instance directly or with factory that was instantiated with specific sapi name (for example: cli) or empty string. You can also resolve it automatically and create either UploadedFile or NonSAPIUploadedFile depending on predefined PHP_SAPI constant:


All versions of message with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
ext-json Version *
psr/http-message Version ^1.1 || ^2.0
psr/http-factory Version ^1.1
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 polymorphine/message contains the following files

Loading the files please wait ....