Update documentation
This commit is contained in:
parent
32608a6610
commit
3554cc7a0a
|
@ -0,0 +1,34 @@
|
|||
.. title:: Changelog
|
||||
|
||||
Changelog
|
||||
#########
|
||||
|
||||
.. sidebar:: Table of Contents
|
||||
.. contents::
|
||||
|
||||
v1.1.0
|
||||
======
|
||||
|
||||
**New Features:**
|
||||
|
||||
* Extended `documentation <https://opencultureconsulting.github.io/psr-15/>`_
|
||||
|
||||
**Minor Changes:**
|
||||
|
||||
* Added Composer commands for development tools (PHP_CodeSniffer, PHP-CS-Fixer, PHPStan, Psalm and phpDocumentor)
|
||||
|
||||
**Maintencance:**
|
||||
|
||||
* Updated dependencies
|
||||
|
||||
v1.0.1
|
||||
======
|
||||
|
||||
**Maintenance:**
|
||||
|
||||
* Updated dependencies
|
||||
|
||||
v1.0.0
|
||||
======
|
||||
|
||||
**Initial Release**
|
|
@ -0,0 +1,11 @@
|
|||
.. title:: PSR-15 Queue
|
||||
|
||||
Documentation
|
||||
#############
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
overview/index
|
||||
usage/index
|
||||
changelog
|
|
@ -0,0 +1,5 @@
|
|||
.. title:: AbstractMiddleware
|
||||
|
||||
AbstractMiddleware
|
||||
##################
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
.. title:: Overview
|
||||
|
||||
Overview
|
||||
########
|
||||
|
||||
The package contains an implementation of `PSR-15: HTTP Server Request Handlers <https://www.php-fig.org/psr/psr-15/>`_
|
||||
in a queue-based variant. A :doc:`queuerequesthandler` handles an incoming HTTP request by passing it through a queue
|
||||
of one or more middlewares. The :doc:`middlewarequeue` provides the middlewares in first-in, first-out (FIFO) order,
|
||||
i.e. the HTTP request is passed from middleware to middleware preserving the order in which the middlewares were added
|
||||
to the queue. An :doc:`abstractmiddleware` helps developing your own middlewares, but you can also use any middleware
|
||||
implementing the `Psr\Http\Server\MiddlewareInterface <https://packagist.org/packages/psr/http-server-middleware>`_.
|
||||
|
||||
All files share the highest coding standards of `PHPStan <https://phpstan.org/>`_ and `Psalm <https://psalm.dev/>`_,
|
||||
and full `PSR-12 <https://www.php-fig.org/psr/psr-12/>`_ compliance to make sure they can be combined and easily used
|
||||
in other projects.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
queuerequesthandler
|
||||
middlewarequeue
|
||||
abstractmiddleware
|
|
@ -0,0 +1,5 @@
|
|||
.. title:: MiddlewareQueue
|
||||
|
||||
MiddlewareQueue
|
||||
###############
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
.. title:: QueueRequestHandler
|
||||
|
||||
QueueRequestHandler
|
||||
###################
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
.. title:: User Guide
|
||||
|
||||
User Guide
|
||||
##########
|
||||
|
||||
The *Queue-based HTTP Server Request Handler* is a library package, not a stand-alone application. The following
|
||||
documentation of requirements and installation procedures describes how to make use of the classes within your own
|
||||
application. For a detailed description of the package's contents have a look at the :doc:`../overview/index` page.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
requirements
|
||||
installation
|
||||
usage
|
|
@ -0,0 +1,59 @@
|
|||
.. title:: Installation
|
||||
|
||||
Installation
|
||||
############
|
||||
|
||||
.. sidebar:: Table of Contents
|
||||
.. contents::
|
||||
|
||||
Composer
|
||||
========
|
||||
|
||||
The intended and recommended way of re-using this package is via `Composer <https://getcomposer.org/>`_. The following
|
||||
command will get you the latest version and make it a dependency of your project. It will also request all dependencies
|
||||
and register all classes with the autoloader to make them available inside the application.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
# This will install the latest stable version suitable for your project
|
||||
composer require "opencultureconsulting/psr15"
|
||||
|
||||
If you want to use a specific version other than the latest available for your environment, you can do so by appending
|
||||
the desired version constraint:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
# This will install the latest patch level version of 1.1 (i. e. >=1.1.0 && <1.2.0)
|
||||
composer require "opencultureconsulting/psr15:~1.1"
|
||||
|
||||
All available versions as well as further information about :doc:`requirements` and dependencies can be found on
|
||||
`Packagist <https://packagist.org/packages/opencultureconsulting/psr15>`_.
|
||||
|
||||
Git
|
||||
===
|
||||
|
||||
Alternatively, you can fetch the files from `GitHub <https://github.com/opencultureconsulting/psr-15>`_ and add them to
|
||||
your project manually. The best way is by cloning the repository, because then you can easily update to a newer version
|
||||
by just pulling the changes and checking out a different version tag.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
# This will clone the repository into the "psr15" directory
|
||||
git clone https://github.com/opencultureconsulting/psr-15.git psr15
|
||||
|
||||
If you want to use a specific version other than the latest development state, you have to specify the desired tag as
|
||||
well:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
# This will clone the repository state at version "1.1.0" into the "psr15" directory
|
||||
git clone --branch=v1.1.0 https://github.com/opencultureconsulting/psr-15.git psr15
|
||||
|
||||
Be aware that you also need to make the classes available in your application by either adding them to your autoloader
|
||||
or by including all files individually in PHP. Also don't forget to do the same for all :doc:`requirements`.
|
||||
|
||||
Download
|
||||
========
|
||||
|
||||
As a last resort you can also just download the files. You can find all available versions as well as the current
|
||||
development state on the `GitHub release page <https://github.com/opencultureconsulting/psr-15/releases>`_.
|
|
@ -0,0 +1,27 @@
|
|||
.. title:: Requirements
|
||||
|
||||
Requirements
|
||||
############
|
||||
|
||||
Environment
|
||||
===========
|
||||
|
||||
This package requires at least **PHP 8.1**.
|
||||
|
||||
It is highly recommended to use `Composer <https://getcomposer.org/>`_ for dependency management and autoloading,
|
||||
although it is technically not strictly required for using any of these classes. But it certainly makes it a lot
|
||||
easier!
|
||||
|
||||
Dependencies
|
||||
============
|
||||
|
||||
This package obviously depends on `psr/http-server-handler <https://packagist.org/packages/psr/http-server-handler>`_
|
||||
and `psr/http-server-middleware <https://packagist.org/packages/psr/http-server-middleware>`_ which define the standard
|
||||
`PSR-15: HTTP Server Request Handlers <https://www.php-fig.org/psr/psr-15/>`_ interfaces.
|
||||
|
||||
It uses the `PSR-7: HTTP Message <https://www.php-fig.org/psr/psr-7/>`_ implementations for server request and response
|
||||
of the great `guzzlehttp/psr7 <https://packagist.org/packages/guzzlehttp/psr7>`_ library.
|
||||
|
||||
The middleware queue is based on a `StrictQueue <https://opencultureconsulting.github.io/php-basics/guides/overview/datastructures.html#strictqueue>`_
|
||||
of the `opencultureconsulting/basics <https://packagist.org/packages/opencultureconsulting/basics>`_ package which also
|
||||
provides some useful traits.
|
|
@ -0,0 +1,157 @@
|
|||
.. title:: Usage
|
||||
|
||||
Usage
|
||||
#####
|
||||
|
||||
.. sidebar:: Table of Contents
|
||||
.. contents::
|
||||
|
||||
The following example shows a very basic *Queue-based HTTP Server Request Handler* using just two simple middlewares
|
||||
(called `MiddlewareOne` and `MiddlewareTwo`).
|
||||
|
||||
Middlewares
|
||||
===========
|
||||
|
||||
First of all, we need some middlewares to process our server request. Although we could use any middleware implementing
|
||||
the `Psr/Http/Server/MiddlewareInterface` (e.g. from `this great collection <https://github.com/middlewares>`_), we
|
||||
will write our own using the :doc:`../overview/abstractmiddleware` provided by this package.
|
||||
|
||||
The abstract middleware already implements a complete middleware, but it will just pass requests through without doing
|
||||
anything. In order to have it do something, we need to implement our own :php:method:`OCC\PSR15\AbstractMiddleware::processRequest()`
|
||||
or :php:method:`OCC\PSR15\AbstractMiddleware::processResponse()` method, or both of them.
|
||||
|
||||
The logic here is the same as with every `PSR-15: HTTP Server Request Handler <https://www.php-fig.org/psr/psr-15/>`_
|
||||
middleware: The request gets passed through all middlewares' `processRequest()` methods in order of their addition to
|
||||
the queue, then a response is created and passed through all `processResponse()` methods, **but in reverse order**! So
|
||||
the first middleware in the queue gets the request first, but the response last.
|
||||
|
||||
Our first middleware is very simple and just adds an attribute to the server request.
|
||||
|
||||
.. code-block:: php
|
||||
use OCC\PSR15\AbstractMiddleware;
|
||||
use Psr\Http\Message\ServerRequestInterface as ServerRequest;
|
||||
|
||||
class MiddlewareOne extends AbstractMiddleware
|
||||
{
|
||||
/**
|
||||
* Process an incoming server request before delegating to next middleware.
|
||||
*
|
||||
* @param ServerRequest $request The incoming server request
|
||||
*
|
||||
* @return ServerRequest The processed server request
|
||||
*/
|
||||
protected function processRequest(ServerRequest $request): ServerRequest
|
||||
{
|
||||
// Let's just add a new attribute to the request to later check
|
||||
// which middleware was passed last.
|
||||
return $request->withAttribute('LastMiddlewarePassed', 'MiddlewareOne');
|
||||
}
|
||||
}
|
||||
|
||||
For a queue to make sense we need at least a second middleware, so let's create another one. Again, we will add an
|
||||
attribute to the request, but with the same name. So, whichever middleware handles the request last overwrites the
|
||||
attribute with its value. This way we can later check if our middlewares were passed in the correct order.
|
||||
|
||||
.. code-block:: php
|
||||
use OCC\PSR15\AbstractMiddleware;
|
||||
use Psr\Http\Message\ServerRequestInterface as ServerRequest;
|
||||
|
||||
class MiddlewareTwo extends AbstractMiddleware
|
||||
{
|
||||
/**
|
||||
* Process an incoming server request before delegating to next middleware.
|
||||
*
|
||||
* @param ServerRequest $request The incoming server request
|
||||
*
|
||||
* @return ServerRequest The processed server request
|
||||
*/
|
||||
protected function processRequest(ServerRequest $request): ServerRequest
|
||||
{
|
||||
// We add the same request attribute as in MiddlewareOne, effectively
|
||||
// overwriting its value.
|
||||
return $request->withAttribute('LastMiddlewarePassed', 'MiddlewareTwo');
|
||||
}
|
||||
}
|
||||
|
||||
Also, we want to set the status code of the response according to the final value of our request attribute. Therefore,
|
||||
we need to implement `processResponse()` as well. We can do that in either one of our middlewares because it's the only
|
||||
response manipulation in our example, so the order of processing doesn't make a difference (remember: `MiddlewareTwo`
|
||||
gets to handle the response before `MiddlewareOne`). Let's go with `MiddlewareTwo`.
|
||||
|
||||
.. code-block:: php
|
||||
use OCC\PSR15\AbstractMiddleware;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as ServerRequest;
|
||||
|
||||
class MiddlewareTwo extends AbstractMiddleware
|
||||
{
|
||||
// MiddlewareTwo::processRequest() remains unchanged (see above).
|
||||
|
||||
/**
|
||||
* Process an incoming response before returning it to previous middleware.
|
||||
*
|
||||
* @param Response $response The incoming response
|
||||
*
|
||||
* @return Response The processed response
|
||||
*/
|
||||
protected function processResponse(Response $response): Response
|
||||
{
|
||||
// First we need to get the request attribute.
|
||||
$lastMiddlewarePassed = $this->requestHandler->request->getAttribute('LastMiddlewarePassed');
|
||||
if ($lastMiddlewarePassed === 'MiddlewareTwo') {
|
||||
// Great, MiddlewareTwo was passed after MiddlewareOne,
|
||||
// let's return status code 200!
|
||||
return $response->withStatus(200);
|
||||
} else {
|
||||
// Oh no, something went wrong! We'll send status code 500.
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Well done! We now have two middlewares.
|
||||
|
||||
Request Handler
|
||||
===============
|
||||
|
||||
Let's use a :doc:`../overview/queuerequesthandler` to pass a server request through both of our middlewares in the
|
||||
correct order.
|
||||
|
||||
.. code-block:: php
|
||||
use OCC\PSR15\QueueRequestHandler;
|
||||
|
||||
// First of all, we instantiate the request handler.
|
||||
// At this point we could already provide an array of middlewares as argument and
|
||||
// skip the next step, but then we wouldn't learn how to use the MiddlewareQueue.
|
||||
$requestHandler = new QueueRequestHandler();
|
||||
|
||||
// We can access the MiddlewareQueue as a property of the request handler.
|
||||
// Let's add both of our middlewares, MiddlewareOne and MiddlewareTwo. Since
|
||||
// this is a FIFO queue, the order is very important!
|
||||
$requestHandler->queue->enqueue(new MiddlewareOne());
|
||||
$requestHandler->queue->enqueue(new MiddlewareTwo());
|
||||
|
||||
// And we are ready to handle incoming requests!
|
||||
// We don't even need to pass the server request to this method, because
|
||||
// the constructor already took care of that!
|
||||
$finalResponse = $requestHandler->handle();
|
||||
|
||||
// Now we can pass the final response back to our application.
|
||||
// Alternatively, we can also return it directly to the client.
|
||||
$requestHandler->respond();
|
||||
|
||||
// If we did everything right, the client should now receive an HTTP response
|
||||
// with status code 200 (OK).
|
||||
|
||||
And that's it!
|
||||
|
||||
Diving Deeper
|
||||
=============
|
||||
|
||||
To familiarize yourself with the FIFO principle of the middleware queue, you can try to exchange the two lines adding
|
||||
the middlewares to the queue, i.e. adding `MiddlewareTwo` first and `MiddlewareOne` second. This will result in an HTTP
|
||||
response with status code `500 (Internal Server Error)`.
|
||||
|
||||
This is exactly what we intended: Have a look at `MiddlewareTwo::processResponse()` again! If `$lastMiddlewarePassed`
|
||||
is not `MiddlewareTwo` (which it isn't when `MiddlewareOne` is added to the queue after `MiddlewareTwo`), we set the
|
||||
response status code to `500`.
|
|
@ -0,0 +1,31 @@
|
|||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
{% for version in project.versions %}
|
||||
{% for toc in version.tableOfContents %}
|
||||
<section class="phpdocumentor-sidebar__category -{{ toc.name|lower }}">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">{{ toc.name|title }}</h2>
|
||||
{% for root in toc.roots %}
|
||||
{{ toc(root, 'components/menu.html.twig', 1) }}
|
||||
{% endfor %}
|
||||
</section>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
{% if project.settings.custom['graphs.enabled'] %}
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="graphs/classes.html">Class Diagram</a></h3>
|
||||
{% endif %}
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
|
@ -0,0 +1,19 @@
|
|||
{% for version in project.versions %}
|
||||
{% for toc in version.tableOfContents|filter(toc => toc.name|lower == "documentation" or toc.name|lower == "packages") %}
|
||||
<h4 id="toc-{{ toc.name|lower }}">{{ toc.name|title }}</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
{% for root in toc.roots %}
|
||||
<dt class="phpdocumentor-table-of-contents__entry -{{ toc.name|lower|trim('s', 'right') }}">
|
||||
<a href="{{ root.url }}">{{ root.title|shortFQSEN }}</a>
|
||||
</dt>
|
||||
{% if root.children.count > 0 %}
|
||||
<dd>
|
||||
{% for child in root.children %}
|
||||
<a href="{{ child.url }}">{{ child.title|shortFQSEN }}</a><br/>
|
||||
{% endfor %}
|
||||
</dd>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</dl>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
|
@ -0,0 +1,30 @@
|
|||
{%
|
||||
set topMenu = {
|
||||
"menu": [
|
||||
{ "iconClass": "fab fa-php", "url": "https://packagist.org/packages/opencultureconsulting/basics"},
|
||||
{ "iconClass": "fab fa-github", "url": "https://github.com/opencultureconsulting/php-basics"}
|
||||
]
|
||||
}
|
||||
%}
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
{% for key,menu in topMenu|default([]) %}
|
||||
{% for menuitem in menu %}
|
||||
<li class="phpdocumentor-topnav__menu-item -{{ key }}">
|
||||
<a href="{{ menuitem.url }}">
|
||||
<span>
|
||||
{% if menuitem.icon %}
|
||||
<i class="fab fa-{{ menuitem.icon }}">{{ menuitem.icon }}</i>
|
||||
{% endif %}
|
||||
{% if menuitem.iconClass %}
|
||||
<i class="{{ menuitem.iconClass }}"></i>
|
||||
{% endif %}
|
||||
{{ menuitem.name }}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</nav>
|
|
@ -0,0 +1,134 @@
|
|||
aside.phpdocumentor-sidebar
|
||||
{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
aside.phpdocumentor-sidebar
|
||||
section.-documentation
|
||||
{
|
||||
order: 1;
|
||||
}
|
||||
|
||||
aside.phpdocumentor-sidebar
|
||||
section.-packages
|
||||
{
|
||||
order: 2;
|
||||
}
|
||||
|
||||
aside.phpdocumentor-sidebar
|
||||
section.-namespaces
|
||||
{
|
||||
order: 3;
|
||||
}
|
||||
|
||||
aside.phpdocumentor-sidebar
|
||||
section.-reports
|
||||
{
|
||||
order: 4;
|
||||
}
|
||||
|
||||
aside.phpdocumentor-sidebar
|
||||
section.-indices
|
||||
{
|
||||
order: 5;
|
||||
}
|
||||
|
||||
aside.phpdocumentor-sidebar
|
||||
ul.phpdocumentor-list
|
||||
{
|
||||
padding: 0 var(--spacing-md) !important;
|
||||
}
|
||||
|
||||
p > code,
|
||||
li > code,
|
||||
code.prettyprint
|
||||
{
|
||||
background-color: var(--code-background-color);
|
||||
border: 1px solid #f0f0f0;
|
||||
border-radius: var(--border-radius-base-size);
|
||||
box-sizing: border-box;
|
||||
font-size: var(--text-sm);
|
||||
padding: var(--spacing-xxxs);
|
||||
}
|
||||
|
||||
@media (max-width: 999px) {
|
||||
div.admonition-wrapper
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1000px) {
|
||||
div.admonition-wrapper
|
||||
{
|
||||
display: block;
|
||||
float: right;
|
||||
padding: var(--spacing-md);
|
||||
margin: 0 0 var(--spacing-md) var(--spacing-md);
|
||||
width: auto;
|
||||
font-size: var(--text-sm);
|
||||
border: 1px solid var(--primary-color-lighten);
|
||||
}
|
||||
}
|
||||
|
||||
div.admonition-wrapper
|
||||
p.sidebar-title
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.contents
|
||||
ul.phpdocumentor-list
|
||||
{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.phpdocumentor-content
|
||||
div.section
|
||||
ul
|
||||
{
|
||||
padding-left: var(--spacing-lg);
|
||||
}
|
||||
|
||||
div.phpdocumentor-content
|
||||
div.section
|
||||
ul
|
||||
li
|
||||
{
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
|
||||
dl.phpdocumentor-table-of-contents
|
||||
dt.phpdocumentor-table-of-contents__entry.-documentation:before
|
||||
{
|
||||
content: 'D';
|
||||
}
|
||||
|
||||
h2.phpdocumentor-content__title
|
||||
{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
h2.phpdocumentor-content__title
|
||||
div.phpdocumentor-element__package
|
||||
{
|
||||
order: 1;
|
||||
}
|
||||
|
||||
h2.phpdocumentor-content__title
|
||||
span.phpdocumentor-element__extends,
|
||||
h2.phpdocumentor-content__title
|
||||
span.phpdocumentor-element__implements
|
||||
{
|
||||
font-size: calc(var(--text-xxs) / 1.2 / 1.2);
|
||||
order: 2;
|
||||
}
|
||||
|
||||
h2.phpdocumentor-content__title
|
||||
span:first-letter
|
||||
{
|
||||
text-transform: lowercase;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<section>
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
<li><a href>Home</a></li>
|
||||
</ul>
|
||||
|
||||
<h2 class="phpdocumentor-content__title">Queue-based HTTP Server Request Handler</h2>
|
||||
|
||||
<p class="phpdocumentor-summary">An implementation of <a href="https://www.php-fig.org/psr/psr-15/">PSR-15: HTTP
|
||||
Server Request Handlers</a>.</p>
|
||||
|
||||
<p>The PHP Standard Recommendation PSR-15 defines interfaces for server request handlers and proposes a queue-based
|
||||
implementation using different middlewares for processing requests and preparing responses. This package follows
|
||||
those guidelines and provides a <a href="guides/overview/queuerequesthandler.html">HTTP server request handler</a>
|
||||
implementation using a <a href="guides/overview/middlewarequeue.html">middleware queue</a>. It also contains an
|
||||
<a href="guides/overview/abstractmiddleware.html">abstract class for middlewares</a> to ease the process of writing
|
||||
your own middleware, but you can just as well use any middleware that implements the middleware interface specified
|
||||
by PSR-15 (e.g. from the awesome <a href="https://github.com/middlewares">PSR-15 HTTP Middlewares</a> project).</p>
|
||||
|
||||
<p>All components of this package follow the highest coding standards of <a href="https://phpstan.org/">PHPStan</a>
|
||||
and <a href="https://psalm.dev/">Psalm</a>, and comply to <a href="https://www.php-fig.org/psr/psr-12/">PSR-12</a>
|
||||
code style guidelines to make sure they can be combined and easily re-used in other projects.</p>
|
||||
|
||||
<h3 id="toc">Table of Contents</h3>
|
||||
|
||||
{% include('components/toc.html.twig') %}
|
||||
</section>
|
||||
{% endblock %}
|
|
@ -4,13 +4,15 @@
|
|||
|
||||
The PHP Standard Recommendation PSR-15 defines interfaces for server request handlers and proposes a queue-based implementation using different middlewares for processing requests and preparing responses. This package follows those guidelines and provides a [HTTP server request handler](src/QueueRequestHandler.php) implementation using a [middleware queue](src/MiddlewareQueue.php). It also contains an [abstract class for middlewares](src/AbstractMiddleware.php) to ease the process of writing your own middleware, but you can just as well use any middleware that implements `Psr\Http\Server\MiddlewareInterface` specified by PSR-15 (e.g. from the awesome [PSR-15 HTTP Middlewares](https://github.com/middlewares) project).
|
||||
|
||||
All components of this package follow the highest coding standards of [PHPStan](https://phpstan.org/) and [Psalm](https://psalm.dev/), and comply to [PSR-12](https://www.php-fig.org/psr/psr-12/) code style guidelines to make sure they can be combined and easily re-used in other projects.
|
||||
All components of this package follow the highest coding standards of [PHPStan](https://phpstan.org/) and [Psalm](https://psalm.dev/), and comply to [PSR-12](https://www.php-fig.org/psr/psr-12/) code style guidelines to make sure they can be combined and easily used in other projects.
|
||||
|
||||
## Quick Start
|
||||
|
||||
The intended and recommended way of re-using this package is via [Composer](https://getcomposer.org/). The following command will get you the latest version:
|
||||
The intended and recommended way of using this package is via [Composer](https://getcomposer.org/). The following command will get you the latest version:
|
||||
|
||||
composer require opencultureconsulting/psr15
|
||||
```shell
|
||||
composer require opencultureconsulting/psr15
|
||||
```
|
||||
|
||||
All available versions as well as further information about requirements and dependencies can be found on [Packagist](https://packagist.org/packages/opencultureconsulting/psr15).
|
||||
|
||||
|
|
|
@ -0,0 +1,681 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PSR-15 Queue</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PSR-15 Queue</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/queuerequesthandler.html#queuerequesthandler" class="">QueueRequestHandler</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/middlewarequeue.html#middlewarequeue" class="">MiddlewareQueue</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/abstractmiddleware.html#abstractmiddleware" class="">AbstractMiddleware</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/usage.html#usage" class="">Usage</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-psr15.html" class="">PSR15</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/PSR15.html" class="">PSR15</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<section>
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ.html">OCC</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ-psr15.html">PSR15</a></li>
|
||||
</ul>
|
||||
|
||||
<article class="phpdocumentor-element -class">
|
||||
<h2 class="phpdocumentor-content__title">
|
||||
AbstractMiddleware
|
||||
|
||||
|
||||
<div class="phpdocumentor-element__package">
|
||||
in package
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
<li class="phpdocumentor-breadcrumb"><a href="packages/PSR15.html">PSR15</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<span class="phpdocumentor-element__implements">
|
||||
implements
|
||||
<abbr title="\Psr\Http\Server\MiddlewareInterface">MiddlewareInterface</abbr> </span>
|
||||
|
||||
</h2>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
|
||||
|
||||
<div class="phpdocumentor-label phpdocumentor-label--success"><span>Abstract</span><span>Yes</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/AbstractMiddleware.php"><a href="files/src-abstractmiddleware.html"><abbr title="src/AbstractMiddleware.php">AbstractMiddleware.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">36</span>
|
||||
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#source-view.36" class="phpdocumentor-element-found-in__source" data-line="36" data-modal="source-view" data-src="files/src/AbstractMiddleware.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Abstract class implementing \Psr\Http\Server\MiddlewareInterface.</p>
|
||||
|
||||
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-tag-list__heading" id="tags">
|
||||
Tags
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#tags" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h5>
|
||||
<dl class="phpdocumentor-tag-list">
|
||||
<dt class="phpdocumentor-tag-list__entry">
|
||||
<span class="phpdocumentor-tag__name">author</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
|
||||
<section class="phpdocumentor-description"><p>Sebastian Meyer <a href="mailto:sebastian.meyer@opencultureconsulting.com">sebastian.meyer@opencultureconsulting.com</a></p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 id="toc">
|
||||
Table of Contents
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#toc" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
|
||||
|
||||
|
||||
<h4 id="toc-interfaces">
|
||||
Interfaces
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#toc-interfaces" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -interface"><abbr title="\Psr\Http\Server\MiddlewareInterface">MiddlewareInterface</abbr></dt> </dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 id="toc-methods">
|
||||
Methods
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#toc-methods" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a class="" href="classes/OCC-PSR15-AbstractMiddleware.html#method___invoke">__invoke()</a>
|
||||
<span>
|
||||
: <abbr title="\Psr\Http\Message\ResponseInterface">ResponseInterface</abbr> </span>
|
||||
</dt>
|
||||
<dd>Allow the middleware to be invoked directly.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a class="" href="classes/OCC-PSR15-AbstractMiddleware.html#method_process">process()</a>
|
||||
<span>
|
||||
: <abbr title="\Psr\Http\Message\ResponseInterface">ResponseInterface</abbr> </span>
|
||||
</dt>
|
||||
<dd>Process an incoming server request and produce a response.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -protected">
|
||||
<a class="" href="classes/OCC-PSR15-AbstractMiddleware.html#method_processRequest">processRequest()</a>
|
||||
<span>
|
||||
: <abbr title="\Psr\Http\Message\ServerRequestInterface">ServerRequestInterface</abbr> </span>
|
||||
</dt>
|
||||
<dd>Process an incoming server request before delegating to next middleware.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -protected">
|
||||
<a class="" href="classes/OCC-PSR15-AbstractMiddleware.html#method_processResponse">processResponse()</a>
|
||||
<span>
|
||||
: <abbr title="\Psr\Http\Message\ResponseInterface">ResponseInterface</abbr> </span>
|
||||
</dt>
|
||||
<dd>Process an incoming response before returning it to previous middleware.</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section class="phpdocumentor-methods">
|
||||
<h3 class="phpdocumentor-elements__header" id="methods">
|
||||
Methods
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#methods" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-public
|
||||
-final "
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method___invoke">
|
||||
__invoke()
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#method___invoke" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/AbstractMiddleware.php"><a href="files/src-abstractmiddleware.html"><abbr title="src/AbstractMiddleware.php">AbstractMiddleware.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">105</span>
|
||||
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#source-view.105" class="phpdocumentor-element-found-in__source" data-line="105" data-modal="source-view" data-src="files/src/AbstractMiddleware.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Allow the middleware to be invoked directly.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__final">final</span> <span class="phpdocumentor-signature__name">__invoke</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Message\ServerRequestInterface">ServerRequestInterface</abbr> </span><span class="phpdocumentor-signature__argument__name">$request</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Server\RequestHandlerInterface">RequestHandlerInterface</abbr> </span><span class="phpdocumentor-signature__argument__name">$handler</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type"><abbr title="\Psr\Http\Message\ResponseInterface">ResponseInterface</abbr></span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
<div class="phpdocumentor-label phpdocumentor-label--success"><span>API</span><span>Yes</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$request</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Message\ServerRequestInterface">ServerRequestInterface</abbr></span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The server request to process</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$handler</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Server\RequestHandlerInterface">RequestHandlerInterface</abbr></span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The request handler to delegate to</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type"><abbr title="\Psr\Http\Message\ResponseInterface">ResponseInterface</abbr></span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>The response object</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-public
|
||||
-final "
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_process">
|
||||
process()
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#method_process" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/AbstractMiddleware.php"><a href="files/src-abstractmiddleware.html"><abbr title="src/AbstractMiddleware.php">AbstractMiddleware.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">57</span>
|
||||
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#source-view.57" class="phpdocumentor-element-found-in__source" data-line="57" data-modal="source-view" data-src="files/src/AbstractMiddleware.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Process an incoming server request and produce a response.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__final">final</span> <span class="phpdocumentor-signature__name">process</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Message\ServerRequestInterface">ServerRequestInterface</abbr> </span><span class="phpdocumentor-signature__argument__name">$request</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Server\RequestHandlerInterface">RequestHandlerInterface</abbr> </span><span class="phpdocumentor-signature__argument__name">$handler</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type"><abbr title="\Psr\Http\Message\ResponseInterface">ResponseInterface</abbr></span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
<div class="phpdocumentor-label phpdocumentor-label--success"><span>API</span><span>Yes</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$request</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Message\ServerRequestInterface">ServerRequestInterface</abbr></span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The server request to process</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$handler</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Server\RequestHandlerInterface">RequestHandlerInterface</abbr></span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The request handler to delegate to</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type"><abbr title="\Psr\Http\Message\ResponseInterface">ResponseInterface</abbr></span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>The response object</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-protected
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_processRequest">
|
||||
processRequest()
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#method_processRequest" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/AbstractMiddleware.php"><a href="files/src-abstractmiddleware.html"><abbr title="src/AbstractMiddleware.php">AbstractMiddleware.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">78</span>
|
||||
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#source-view.78" class="phpdocumentor-element-found-in__source" data-line="78" data-modal="source-view" data-src="files/src/AbstractMiddleware.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Process an incoming server request before delegating to next middleware.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">protected</span>
|
||||
<span class="phpdocumentor-signature__name">processRequest</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Message\ServerRequestInterface">ServerRequestInterface</abbr> </span><span class="phpdocumentor-signature__argument__name">$request</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type"><abbr title="\Psr\Http\Message\ServerRequestInterface">ServerRequestInterface</abbr></span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
</div>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$request</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Message\ServerRequestInterface">ServerRequestInterface</abbr></span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The incoming server request</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type"><abbr title="\Psr\Http\Message\ServerRequestInterface">ServerRequestInterface</abbr></span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>The processed server request</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-protected
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_processResponse">
|
||||
processResponse()
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#method_processResponse" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/AbstractMiddleware.php"><a href="files/src-abstractmiddleware.html"><abbr title="src/AbstractMiddleware.php">AbstractMiddleware.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">90</span>
|
||||
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#source-view.90" class="phpdocumentor-element-found-in__source" data-line="90" data-modal="source-view" data-src="files/src/AbstractMiddleware.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Process an incoming response before returning it to previous middleware.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">protected</span>
|
||||
<span class="phpdocumentor-signature__name">processResponse</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Message\ResponseInterface">ResponseInterface</abbr> </span><span class="phpdocumentor-signature__argument__name">$response</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type"><abbr title="\Psr\Http\Message\ResponseInterface">ResponseInterface</abbr></span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
</div>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$response</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type"><abbr title="\Psr\Http\Message\ResponseInterface">ResponseInterface</abbr></span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The incoming response</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type"><abbr title="\Psr\Http\Message\ResponseInterface">ResponseInterface</abbr></span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>The processed response</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<div class="phpdocumentor-modal" id="source-view">
|
||||
<div class="phpdocumentor-modal-bg" data-exit-button></div>
|
||||
<div class="phpdocumentor-modal-container">
|
||||
<div class="phpdocumentor-modal-content">
|
||||
<pre style="max-height: 500px; overflow-y: scroll" data-src="files/src/AbstractMiddleware.php.txt" class="language-php line-numbers linkable-line-numbers"></pre>
|
||||
</div>
|
||||
<button data-exit-button class="phpdocumentor-modal__close">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
function loadExternalCodeSnippet(el, url, line) {
|
||||
Array.prototype.slice.call(el.querySelectorAll('pre[data-src]')).forEach((pre) => {
|
||||
const src = url || pre.getAttribute('data-src').replace(/\\/g, '/');
|
||||
const language = 'php';
|
||||
|
||||
const code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
pre.textContent = '';
|
||||
pre.setAttribute('data-line', line)
|
||||
code.textContent = 'Loading…';
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
Prism.highlightElement(code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status === 404) {
|
||||
code.textContent = '✖ Error: File could not be found';
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
return;
|
||||
}
|
||||
|
||||
code.textContent = '✖ Error: An unknown error occurred';
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
const modalButtons = document.querySelectorAll("[data-modal]");
|
||||
const openedAsLocalFile = window.location.protocol === 'file:';
|
||||
if (modalButtons.length > 0 && openedAsLocalFile) {
|
||||
console.warn(
|
||||
'Viewing the source code is unavailable because you are opening this page from the file:// scheme; ' +
|
||||
'browsers block XHR requests when a page is opened this way'
|
||||
);
|
||||
}
|
||||
|
||||
modalButtons.forEach(function (trigger) {
|
||||
if (openedAsLocalFile) {
|
||||
trigger.setAttribute("hidden", "hidden");
|
||||
}
|
||||
|
||||
trigger.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
const modal = document.getElementById(trigger.dataset.modal);
|
||||
if (!modal) {
|
||||
console.error(`Modal with id "${trigger.dataset.modal}" could not be found`);
|
||||
return;
|
||||
}
|
||||
modal.classList.add("phpdocumentor-modal__open");
|
||||
|
||||
loadExternalCodeSnippet(modal, trigger.dataset.src || null, trigger.dataset.line)
|
||||
const exits = modal.querySelectorAll("[data-exit-button]");
|
||||
exits.forEach(function (exit) {
|
||||
exit.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
modal.classList.remove("phpdocumentor-modal__open");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
</article>
|
||||
</section>
|
||||
<section class="phpdocumentor-on-this-page__sidebar">
|
||||
|
||||
<section class="phpdocumentor-on-this-page__content">
|
||||
<strong class="phpdocumentor-on-this-page__title">On this page</strong>
|
||||
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li class="phpdocumentor-on-this-page-section__title">Table Of Contents</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="classes/OCC-PSR15-AbstractMiddleware.html#toc-methods">Methods</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
<li class="phpdocumentor-on-this-page-section__title">Methods</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li class=""><a href="classes/OCC-PSR15-AbstractMiddleware.html#method___invoke">__invoke()</a></li>
|
||||
<li class=""><a href="classes/OCC-PSR15-AbstractMiddleware.html#method_process">process()</a></li>
|
||||
<li class=""><a href="classes/OCC-PSR15-AbstractMiddleware.html#method_processRequest">processRequest()</a></li>
|
||||
<li class=""><a href="classes/OCC-PSR15-AbstractMiddleware.html#method_processResponse">processResponse()</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="classes/OCC-PSR15-AbstractMiddleware.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,509 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PSR-15 Queue</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PSR-15 Queue</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/queuerequesthandler.html#queuerequesthandler" class="">QueueRequestHandler</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/middlewarequeue.html#middlewarequeue" class="">MiddlewareQueue</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/abstractmiddleware.html#abstractmiddleware" class="">AbstractMiddleware</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/usage.html#usage" class="">Usage</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-psr15.html" class="">PSR15</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/PSR15.html" class="">PSR15</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<section>
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ.html">OCC</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ-psr15.html">PSR15</a></li>
|
||||
</ul>
|
||||
|
||||
<article class="phpdocumentor-element -class">
|
||||
<h2 class="phpdocumentor-content__title">
|
||||