Download the PHP package telegraph/middleware without Composer

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

Telegraph Middleware

This package includes the following Telegraph-compatible middleware:

This package is installable and PSR-4 autoloadable via Composer as telegraph/middleware.

ExceptionHandler

Similarly, the ExceptionHandler does what it sound like: it catches any exceptions that bubble up through the subsequent middleware decorators.

The ExceptionHandler does nothing with the $request , and passes it directly to $next inside a try/catch block. If no exception bubbles up, it returns the $response from $next. However, if it catches an exception, it returns an entirely new $response object with the exception message and an HTTP 500 status code. It then returns the new $response object.

The ExceptionHandler is intended to go near the top of the Telegraph queue, but after the ResponseSender, so that the ResponseSender can then send the returned $response.

To add the ExceptionHandler to your queue, instantiate it directly with an empty $response implementation object ...

... or use a $resolver of your choice to instantiate it from the $queue.

FormContentHandler

FormContentHandler works almost identically to JsonContentHandler (below), but parses payloads of requests that have application/x-www-form-urlencoded as the Content-Type.

JsonContentHandler

Again, the JsonContentHandler does what it sounds like: it deserializes the JSON payload of a PSR-7 request object and makes the parameters available in subsequent middleware decorators.

The JsonContentHandler checks the incoming request for a method other than GET and for an application/json or application/vnd.api+json Content-Type header. If it finds both of these, it parses the JSON and makes it available as the parsed body of the $request before passing it to $next. If the method is GET or the Content-Type header defines a different mime type, the JsonContentHandler ignores the $request and continues the chain.

To add the JsonContentHandler to your queue, instantiate it directly...

... or use a $resolver of your choice to instantiate it from the $queue.

To access the decoded parameters in subsequent middleware, use the getParsedBody() method of the $request

ResponseSender

The ResponseSender does just what it sounds like: it sends the PSR-7 response object.

The ResponseSender does nothing with the $request, passing it immediately to $next. Afterwards, it takes the returned $response and sends it using header() and echo, and returns the sent $response.

The ResponseSender is intended to go at the top of the Telegraph queue, so that it is the middleware with the last opportunity to do something with the returned response.

To add the ResponseSender to your Telegraph queue, instantiate it directly ...

... or use a $resolver of your choice to instantiate it from the $queue.

SessionHeadersHandler

Normally, PHP will send out headers for you automatically when you call session_start(). However, this means the headers are not being sent as part of the PSR-7 response object, and are thus outside your control. This handler puts them back under your control by placing the relevant headers in the PSR-7 response; its behavior is almost identical to the native PHP automatic session headers behavior.

NOTE: For this middleware to work, you must disable the PHP session header management ini settings. For example:

ini_set('session.use_trans_sid', false);
ini_set('session.use_cookies', false);
ini_set('session.use_only_cookies', true);
ini_set('session.cache_limiter', '');

If you do not, the handler will throw a RuntimeException.

To add the SessionHeadersHandler to your queue, instantiate it directly...

... or use a $resolver of your choice to instantiate it from the $queue.

When instantiating, you can pass a cache limiter value as the first constructor parameter. The allowed values are 'nocache', 'public', 'private_no_cache', or 'priviate'. If you want no cache limiter header at all, pass an empty string ''. The default is 'nocache'.

You can also pass a cache expire value, in minutes, as the second constructor parameter. The default is 180 minutes.


All versions of middleware with dependencies

PHP Build Version
Package Version
Requires 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 telegraph/middleware contains the following files

Loading the files please wait ....