Middleware for PHP built on top of PSR-7 and PSR-15

Overview

zend-stratigility

Repository abandoned 2019-12-31

This repository has moved to laminas/laminas-stratigility.

Build Status Coverage Status

From "Strata", Latin for "layer", and "agility".

This package supersedes and replaces phly/conduit.

Stratigility is a port of Sencha Connect to PHP. It allows you to create and dispatch middleware pipelines.

Comments
  • Error handling

    Error handling

    Me and a colleague have been working hard trying to bypass the error handler - we want to use an alternative error handler (booboo) but the middleware stack catches and handles exceptions before they can get to the error handler.

    We noticed the onerror callback in $options of the FinalHandler constructor, but this gets constructed internally in MiddlewarePipe, where everything is declared private, so we had no luck attempting to extend the class in order to provide the option.

    How do we turn off built-in error handling?

    help wanted question Awaiting author feedback 
    opened by mindplay-dk 16
  • Regression on 1.2.0 with Response end

    Regression on 1.2.0 with Response end

    Starting from version 1.2, our app stopped working when an error is thrown in the code.

    In our code, the FinalHandler is map to a custom handler:

    class JsonErrorHandler
    {
        public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $err = null)
        {
            if ($err) {
                return $this->handleError($err, $response);
            }
    
            if (null === $request->getAttribute(RouteResult::class)) {
                return new JsonResponse(['message' => 'Not Found'], 404);
            }
    
            return $response;
        }
    
        private function handleError($err, ResponseInterface $response)
        {
            // To avoid security issue, when the error is an exception, we simply display a 500
            if ($err instanceof Exception) {
                return new JsonResponse(['message' => 'An error occurred'], 500);
            }
    
            return new JsonResponse(['message' => $response->getReasonPhrase()], $response->getStatusCode());
        }
    }
    

    It used to return a JsonResponse when there was an error, but now it throws the RuntimeException error:

    capture d ecran 2016-03-21 a 16 18 53
    opened by bakura10 14
  • Performance - benchmarks?

    Performance - benchmarks?

    I'd like to encourage you to publish some benchmarks.

    I have a middleware stack currently with just one route to a single piece of thin middleware doing nothing fancy, and it's already too slow to be of any use in production. I haven't gotten around to looking for bottlenecks yet, but commenting out the middleware (and just dispatching my router manually) eliminated the performance issue completely, e.g. seconds to run 1000 requests with ab -n 1000 -c 20 vs minutes with the middleware stack in between.

    Have you benchmarked this middleware stack for performance at all?

    opened by mindplay-dk 14
  • Zend\Stratigility\MiddlewarePipe missing dependencies

    Zend\Stratigility\MiddlewarePipe missing dependencies

    Instantiating a MiddlewarePipe instance fails on missing interface dependencies, namely: Webimpress\HttpMiddlewareCompatibility\HandlerInterface, and Webimpress\HttpMiddlewareCompatibility\MiddlewareInterface

    Code to reproduce the issue

    use Interop\Http\Server\RequestHandlerInterface; use Zend\Stratigility{MiddlewarePipe, NoopFinalHandler}; use Zend\Diactoros{Server, Response}; use Psr\Http\Message\ServerRequestInterface;

    require DIR . '/../vendor/autoload.php';

    $pipe = new MiddlewarePipe();

    Expected results

    Pipe instance.

    Actual results

    Fatal error on missing interfaces

    opened by datashuttle 10
  • PSR-7 violations

    PSR-7 violations

    I just spent two hours trying to find out why a middleware was unable to set a header, and it turns out this line of code violates this clause of the spec:

    MUST return an instance that has the new and/or updated header and value.

    The idea of a response being "complete" isn't even a thing in the spec.

    Simply ignoring function calls in this manner makes it very hard to debug anything, and is extremely risky. If I called setHeader() (or any number of other methods) clearly I'm calling them for one reason, and one reason only - quietly ignoring this call is a clear violation of the spec.

    Debugging this type of silent error is an absolute nightmare. Components and middleware worked perfectly in unit and integration tests, but then quietly failed when implemented in production code.

    I'm baffled as to why you would think this feature is necessary in the first place? Request and Response models are already immutable - what possible reason could you have to disable an an already-immutable model instance from generating a new model?

    If a given piece of middleware decides that a response is "complete", quite simply, it won't delegate control to the next middleware on the stack. Instead, this feature allows you to delegate control to the next middleware, but disabling it from actually doing anything - it will run, but can't actually do anything.

    Am I crazy for thinking this is crazy??

    help wanted Awaiting author feedback 
    opened by mindplay-dk 9
  • Deprecate FinalHandler and ErrorMiddlewareInterface

    Deprecate FinalHandler and ErrorMiddlewareInterface

    This patch will provide the forwards compatibility features for the next minor version of Stratigility that implement the RFC on FinalHandler and ErrorMiddlewareInterface removal.

    • [x] Create NotFoundHandler and ErrorHandler middleware
      • NotFoundHandler returns a basic 404 response, always.
      • ErrorHandler:
        • creates a PHP error handler that will throw any errors not in the current error_handler mask as ErrorExceptions.
        • Does a try/catch around $next()
        • Raises a new exception, MissingResponseException, if $next does not return a response.
        • Casts all Throwable/Exception items to error responses:
          • If a boolean true flag is passed to the constructor, it will use the stack trace in the response.
          • Triggers listeners on the instance with the exception/throwable, request, and response, for reporting purposes.
    • [x] Create a no-op final handler that returns the provided response on invocation, ignoring all other arguments.
    • [x] Update MiddlewarePipe to issue a deprecation notice if $out is omitted.
    • [x] Mark Dispatch as deprecated.
    • [x] Update Next to raise deprecation notice when receiving a non-null $err argument.
    • [x] Mark FinalHandler as deprecated.
    • [x] Mark ErrorMiddlewareInterface as deprecated.
    • [x] Write migration guide.

    Notes

    • In order to return a response, each new middleware type (NotFoundHandler, ErrorHandler) accepts a prototype ResponseInterface instance to the constructor; this is then used to generate the returned response in 404/error conditions. This is done to allow re-use with any PSR-7 implementation.
    enhancement BC Break 
    opened by weierophinney 8
  • Piping and routes

    Piping and routes

    I was having issues using my router as middleware off of Stratigility. Given the following code:

    $router = ...
    $router->get('/', $handler1);
    
    $router2 = ...
    $router2->get('/', $handler2);
    $router2->get('', $handler3);
    
    $app->pipe($router);
    $app->pipe('/articles', $router2);
    

    You would expect / to match the first handler1 and /articles to match handler2. This is not the case, however, as /articles will match handler3 instead. I think there's a leading slash being removed somewhere but I haven't had time to debug it yet.

    This is a fairly critical bug since you won't be able to take a set of routes and move them from one pipe() to another and have them work identical unless you have an optional leading slash in your route or duplicate the route entirely.

    question 
    opened by spiffyjr 8
  • Example in documentation throws a fatal error

    Example in documentation throws a fatal error

    Using 2.0.1 https://zendframework.github.io/zend-stratigility/middleware/

    Will throw

    Fatal error: Uncaught Zend\Stratigility\Exception\MissingResponsePrototypeException:
    Cannot wrap callable middleware; no Zend\Stratigility\Middleware\CallableMiddlewareWrapperFactory
    or Psr\Http\Message\ResponseInterface instances composed in middleware pipeline; use
    setCallableMiddlewareDecorator() or setResponsePrototype() on your Zend\Stratigility\MiddlewarePipe
    instance to provide one or the other, or decorate callable middleware manually before piping.
    
    documentation 
    opened by patrick-fls 7
  • Finalhandler production stacktrace fix

    Finalhandler production stacktrace fix

    @weierophinney this addresses #45 and makes it possible to create the FinalHandler in a factory and worry about the original response later.

    One thing I wasn't sure about was whether error details should be in the case of 'env' !== 'production' vs. 'env' === 'development'. Production is surely "NO" and development is surely "YES", but other environments like staging, qa, etc. may depend on the implementor. Perhaps a boolean display_error_details option would be better than env? If so, what would you do with the original env? Remove it completely? Or automatically set display_error_details to true if env != production and false otherwise for BC?

    enhancement 
    opened by michaelmoussa 7
  • Make `$next` argument required in `MiddlewareInterface`

    Make `$next` argument required in `MiddlewareInterface`

    With the current MiddlewareInterface definition, developers must first validate that $next is non-empty before calling it:

    return ($next ? $next($req, $res) : $res);
    

    This is confusing, and error-prone.

    For version 2, the argument should be required.

    enhancement BC Break 
    opened by weierophinney 7
  • Stratigility - `$next` type hint and project naming question

    Stratigility - `$next` type hint and project naming question

    Hello there,

    I have many questions regarding Stratigility Why choosing a name that will confuse everyone knowing Apigility ?

    Why getting rid of object implementation and only use Callable ? It will cause unused middlewares to be instantiated and serialization issues.

    Finally, how to deal with middleware having more than one children (not just one "next" callable), why having not implemented real workflow around it ?

    It is not just about complaining, I am ready to code what necessary. I just wanna know if this architecture have a purpose I cannot see and is already validated.

    question 
    opened by sophpie 7
  • Moving NotFoundHandler to Handler namespace

    Moving NotFoundHandler to Handler namespace

    Maybe same procedure as in #191

    As the NotFoundHandler is technically a RequestHandler, I am moving it to the Handler namespace instead while marking the NotFoundHandler in the Middleware namespace as deprecated.

    enhancement 
    opened by boesing 2
  • Renaming ErrorHandler to ErrorHandlerMiddleware

    Renaming ErrorHandler to ErrorHandlerMiddleware

    As already mentioned in #190, there is a naming conflict in the ErrorHandler.

    I had some feedback of trainees which asked me, why the ErrorHandler ain't a RequestHandler, as its name says. That made me think about the naming and I realized, its just because of the missing Middleware postfix.

    However, I'd like to rename the ErrorHandler to ErrorHandlerMiddleware to avoid future confusions about where the difference between RequestHandlerInterface and MiddlewareInterface is.

    enhancement 
    opened by boesing 4
  • Naming conflict for

    Naming conflict for "ErrorHandler" which actually is a middleware and not a RequestHandler

    Hey there,

    I am giving some trainings regarding zend-expressive, e.g. for some colleagues. One thing, which always came back to me as a question was:

    Why is the ErrorHandler called ErrorHandler like all those request handlers and not ErrorMiddleware which actually suits better as its a middleware per definition.

    Would like to see the next major version where the ErrorHandler is renamed to ErrorMiddleware.

    Any thoughts on this?

    opened by boesing 3
  • Update creating-middleware.md

    Update creating-middleware.md

    Fixed a typo in $handler invocation in the documentation for creating-middleware.md

    • [ ] Are you fixing a bug?

      • [ ] Detail how the bug is invoked currently.
      • [ ] Detail the original, incorrect behavior.
      • [ ] Detail the new, expected behavior.
      • [ ] Base your feature on the master branch, and submit against that branch.
      • [ ] Add a regression test that demonstrates the bug, and proves the fix.
      • [ ] Add a CHANGELOG.md entry for the fix.
    • [ ] Are you creating a new feature?

      • [ ] Why is the new feature needed? What purpose does it serve?
      • [ ] How will users use the new feature?
      • [ ] Base your feature on the develop branch, and submit against that branch.
      • [ ] Add only one feature per pull request; split multiple features over multiple pull requests
      • [ ] Add tests for the new feature.
      • [ ] Add documentation for the new feature.
      • [ ] Add a CHANGELOG.md entry for the new feature.
    • [ ] Is this related to quality assurance?

    • [x] Is this related to documentation?

    opened by tworzenieweb 3
  • Add documentation describing using Next handler in middlewares

    Add documentation describing using Next handler in middlewares

    Next handler in the pipeline passed as a second parameter to the middleware is not safe to invoke multiple times. What actually Next handler is is defined at runtime and is not guaranteed to be stateless, which can lead to undefined behavior.

    For example, middleware designed to invoke Next handler second time will cause unintented side effects if Fail2Ban middleware is then registered next in the pipeline.

    If handler needs to be invoked multiple times, it should be selected explicitly and injected as a direct dependency (directly or lazy way or as a proxy to a middleware pipe elsewhere, etc).

    opened by Xerkus 1
  • New PathMiddlewareDecorator

    New PathMiddlewareDecorator

    • [x] I was not able to find an open or closed issue matching what I'm seeing.
    • [x] This is not a question.

    I was taking a look to the PathMiddlewareDecorator for a project I'm working on, but it kinda didn't suited my needs.

    • I needed it to match a routes flexibly using regular expressions if necessary.
    • I needed it to match optionally by request route
    • I needed to decide if the middleware being decorated was going to execute if the routed matched or didn't match.

    So I ended up building my own decorator. How keen are you guys of accepting a PR with it? Here's a very naive implementation:

    
    use Psr\Http\Message\ResponseInterface as Response;
    use Psr\Http\Message\ServerRequestInterface as Request;
    use Psr\Http\Server\MiddlewareInterface;
    use Psr\Http\Server\RequestHandlerInterface as NextHandler;
    
    /**
     * Decorates a middleware to be executed on a router pattern match/un-match
     *
     * You can optionally pass a method to the arguments.
     *
     * @author Matías Navarro Carter <[email protected]>
     */
    final class PathMiddlewareDecorator implements MiddlewareInterface
    {
        public const IF_MATCHES = 1;
        public const IF_NOT_MATCHES = 0;
    
        /**
         * @var MiddlewareInterface
         */
        private $middleware;
        /**
         * @var int
         */
        private $executionRule;
        /**
         * @var string|string[]
         */
        private $path;
        /**
         * @var string|null
         */
        private $method;
    
        /**
         * PathMiddlewareDecorator constructor.
         *
         * @param MiddlewareInterface $middleware The middleware to execute.
         * @param string|string[]     $path A path pattern or an array of patterns.
         * @param string|null         $method A method to match.
         * @param int                 $executionRule The rule of execution.
         */
        public function __construct(
            MiddlewareInterface $middleware,
            $path,
            string $method = null,
            int $executionRule = self::IF_MATCHES
        ) {
            $this->middleware = $middleware;
            $this->path = $path;
            $this->method = $method;
            $this->executionRule = $executionRule;
        }
    
        /**
         * @param Request     $request
         * @param NextHandler $handler
         *
         * @return Response
         */
        public function process(Request $request, NextHandler $handler): Response
        {
            $match = $this->matches($request);
    
            if (self::IF_MATCHES === $this->executionRule && true === $match) {
                return $this->middleware->process($request, $handler);
            }
            if (self::IF_NOT_MATCHES === $this->executionRule && false === $match) {
                return $this->middleware->process($request, $handler);
            }
    
            return $handler->handle($request);
        }
    
        /**
         * @param Request $request
         *
         * @return bool
         */
        private function matches(Request $request): bool
        {
            if ($this->method && $request->getMethod() !== $this->method) {
                return false;
            }
    
            return $this->matchesRegex($request->getUri()->getPath(), $this->path);
        }
    
        /**
         * @param string $requestPath
         * @param        $pathOrPaths
         *
         * @return bool
         */
        private function matchesRegex(string $requestPath, $pathOrPaths): bool
        {
            if (is_array($pathOrPaths)) {
                foreach ($pathOrPaths as $string) {
                    $result = $this->matchesRegex($requestPath, $string);
                    if (true === $result) {
                        return true;
                    }
                }
            }
            if (\is_string($pathOrPaths)) {
                return 0 !== preg_match('/'.str_replace('/', '\/', $pathOrPaths).'/', $requestPath);
            }
    
            return false;
        }
    }
    
    

    Of course it should be named differently to the one you guys already have. Maybe ConfigurablePathMiddlewareDecorator?

    opened by mnavarrocarter 2
Releases(3.2.0)
  • 3.2.0(Jun 12, 2019)

    Added

    • Nothing.

    Changed

    • #186 adds a safeguard to middleware pipes to prevent them from being called multiple times within the same middleware. As an example, consider the following middleware:

      public function process(
          ServerRequestInterface $request,
          RequestHandlerInterface $handler
      ) : Response Interface {
          $session = $request->getAttribute('session');
          if (! $session) {
              $response = $handler->handle($request);
          }
      
          // Inject another attribute before handling
          $response = $handler->handle($request->withAttribute(
              'sessionWasEnabled',
              true
          );
          return $response;
      }
      

      When using Stratigility, the $handler is an instance of Zend\Stratigility\Next, which encapsulates the middleware pipeline and advances through it on each call to handle().

      The example demonstrates a subtle error: the response from the first conditional should have been returned, but wasn't, which has led to invoking the handler a second time. This scenario can have unexpected behaviors, including always returning a "not found" response, or returning a response from a handler that was not supposed to execute (as an earlier middleware already returned early in the original call).

      These bugs are hard to locate, as calling handle() is a normal part of any middleware, and multiple conditional calls to it are a standard workflow.

      With this new version, Next will pass a clone of itself to the next middleware in the pipeline, and unset its own internal pipeline queue. Any subsequent requests to handle() within the same scope will therefore result in the exception Zend\Stratigility\Exception\MiddlewarePipeNextHandlerAlreadyCalledException.

      If you depended on calling $handler->handle() multiple times in succession within middleware, we recommend that you compose the specific pipeline(s) and/or handler(s) you wish to call as class dependencies.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 3.1.0(Feb 6, 2019)

    Added

    • #178 adds the class Zend\Stratigility\EmptyPipelineHandler, which raises an EmptyPipelineException when it handles an incoming request. It's primary purpose is for use in the MiddlewarePipe as a fallback handler during handle() operations.

    Changed

    • #178 provides some performance improvements to MiddlewarePipe::handle() by having it create an instance of EmptyPipelineHandler to use as a fallback handler when it calls process() on itself. This prevents cloning of the pipeline in this scenario, which is used when it acts as an application entrypoint.

    • #185 removes the "final" declaration from the ErrorHandler class, to allow more easily mocking it for testing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.3(Feb 6, 2019)

  • 3.0.2(Jul 24, 2018)

    Added

    • Nothing.

    Changed

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • #177 removes a conditional from Zend\Stratigility\Middleware\ErrorHandler that can never be reached.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 2.2.2(Apr 16, 2018)

    Added

    • Nothing.

    Changed

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #169 fixes an issue with how the PathMiddlewareDecorator attempts to truncate the path when the path is matched case insensitively. Previously, an exception was incorrectly raised; now it identifies and truncates correctly.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.1(Apr 4, 2018)

    Added

    • Nothing.

    Changed

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #165 fixes an issue with the PathMiddlewareDecorator whereby it was using the original request when invoking the handler it creates, instead of prepending the configured path prefix to the request URI created. With the fix, if middleware alters the request path passed to the handler, the changes will now propagate to later middleware. As an example:

      new PathMiddlewareDecorator('/api', middleware(function ($request, $handler) {
          $uri = $request->getUri();
          if (! preg_match('#^/v\d+/#', $uri->getPath())) {
              $request = $request->withUri($uri->withPath('/v1' . $uri->getPath()));
          }
          return $handler->handle($request);
      }));
      

      For the request path /api/books, the above will now correctly result in /api/v1/books being propagated to lower layers of the application, instead of /api/books.

    Source code(tar.gz)
    Source code(zip)
  • 2.2.1(Apr 4, 2018)

    Added

    • Nothing.

    Changed

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #167 fixes an issue with the PathMiddlewareDecorator whereby it was using the original request when invoking the handler it creates, instead of prepending the configured path prefix to the request URI created. With the fix, if middleware alters the request path passed to the handler, the changes will now propagate to later middleware. As an example:

      new PathMiddlewareDecorator('/api', middleware(function ($request, $handler) {
          $uri = $request->getUri();
          if (! preg_match('#^/v\d+/#', $uri->getPath())) {
              $request = $request->withUri($uri->withPath('/v1' . $uri->getPath()));
          }
          return $handler->handle($request);
      }));
      

      For the request path /api/books, the above will now correctly result in /api/v1/books being propagated to lower layers of the application, instead of /api/books.

    Source code(tar.gz)
    Source code(zip)
  • 3.0.0(Mar 15, 2018)

    Added

    • #146 adds a new interface, Zend\Stratigility\MiddlewarePipeInterface. It extends the PSR-15 MiddlewareInterface and RequestHandlerInterface, and defines one additional method, pipe(MiddlewareInterface $middleware) : void.

    • #150 adds a new class, Zend\Stratigility\Middleware\RequestHandlerMiddleware. The class implements the PSR-15 RequestHandlerInterface and MiddlewareInterface, and accepts a single constructor argument, a RequestHandlerInterface instance. Each of its handle() and process() methods proxy to the composed request handler's handle() method, returning its result.

      This class can be useful for adapting request handlers to use within pipelines.

    • #142 adds a new class, Zend\Stratigility\Middleware\HostMiddlewareDecorator, which provides host segregation functionality for middleware, allowing conditional execution of middleware only if the requested host matches a configured host.

      // Only process $middleware if the request host matches 'example.com':
      $pipeline->pipe(new HostMiddlewareDecorator('example.com', $middleware));
      

      Additionally, the patch provides a utility function, Zend\Stratigility\host(), to simplify the above declaration:

      $pipeline->pipe(host('example.com', $middleware));
      
    • #128 adds a marker interface, Zend\Stratigility\Exception\ExceptionInterface; all package exceptions now implement this interface, allowing you to catch all package-related exceptions by typehinting against it.

    Changed

    • #145 updates the component to implement and consume ONLY PSR-15 interfaces; http-interop interfaces and callable middleware are no longer directly supported (though Stratigility provides decorators for the latter in order to cast them to PSR-15 implementations).

    • #134 and #146 modify MiddlewarePipe in two ways: it now implements the new MiddlewarePipeInterface, and is marked as final, disallowing direct extension. Either decorate an instance in a custom MiddlewarePipeInterface implementation, or create a custom PSR-15 MiddlewareInterface implementation if piping is not necessary or will allow additional types.

    • #155 modifies each of the following classes to mark them final:

      • Zend\Stratigility\Middleware\CallableMiddlewareDecorator
      • Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator
      • Zend\Stratigility\Middleware\HostMiddlewareDecorator
      • Zend\Stratigility\Middleware\NotFoundHandler
      • Zend\Stratigility\Middleware\OriginalMessages
      • Zend\Stratigility\Middleware\PathMiddlewareDecorator
      • Zend\Stratigility\Middleware\RequestHandlerMiddleware
      • Zend\Stratigility\Next
    • #134, #145, and #146 update MiddlewarePipe to implement Psr\Http\Server\RequestHandlerInterface. Calling it will cause it to pull the first middleware off the queue and create a Next implementation that uses the remaining queue as the request handler; it then processes the middleware.

    • #134 removes the ability to specify a path when calling pipe(); use the PathMiddlewareDecorator or path() utility function to pipe middleware with path segregation.

    • #153 modifies the first argument of the Zend\Expressive\Middleware\ErrorHandler and NotFoundHandler classes. Previously, they each expected a Psr\Http\Message\ResponseInterface instance; they now both expect a PHP callable capable of producing such an instance. This change was done to simplify re-use of a service for producing unique response instances within dependency injection containers.

    • #157 marks the package as conflicting with zendframework/zend-diactoros versions less than 1.7.1. This is due to the fact that that version provides a bugfix for its Uri::getHost() implementation that ensures it follows the PSR-7 and IETF RFC 3986 specifications.

    Deprecated

    • Nothing.

    Removed

    • #163 removes Zend\Stratigility\Middleware\PathRequestHandlerDecorator, as it was deprecated in 2.2, and no longer used with the 3.0 code base.

    • #122 removes support for PHP versions 5.6, 7.0, as well as HHVM.

    • #122 removes the following classes:

      • Zend\Stratigility\Delegate\CallableDelegateDecorator
      • Zend\Stratigility\Exception\InvalidRequestTypeException
      • Zend\Stratigility\Exception\MissingResponsePrototypeException
      • Zend\Stratigility\MiddlewareInterface
      • Zend\Stratigility\Middleware\CallableInteropMiddlewareWrapper
      • Zend\Stratigility\Middleware\CallableMiddlewareWrapper
      • Zend\Stratigility\Middleware\CallableMiddlewareWrapperFactory
      • Zend\Stratigility\NoopFinalHandler
    • #134 removes the class Zend\Stratigility\Route. This was an internal message passed between a MiddlewarePipe and Next instance, and its removal should not affect end users.

    • #134 removes Zend\Stratigility\Exception\InvalidMiddlewareException, as the exception is no longer raised by MiddlewarePipe.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 2.2.0(Mar 12, 2018)

    Added

    • #140 adds the class Zend\Stratigility\Middleware\CallableMiddlewareDecorator for the purpose of decorating callable, standards-signature middleware for use with a MiddlewarePipe instance. Instantiate it directly, passing the callable middleware as the sole argument, or use the Zend\Stratigility\middleware() utility function to generate the instance: middleware($callable).

    • #140 adds the class Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator for the purpose of decorating callable, double-pass middleware for use with a MiddlewarePipe instance. Instantiate it directly, passing the callable middleware and a response instance as arguments, or use the Zend\Stratigility\doublePassMiddleware() utility function to generate the instance: doublePassMiddleware($callable, $response).

    • #140 adds the class Zend\Stratigility\Middleware\PathMiddlewareDecorator for the purposes of creating path-segregated middleware. The constructor expects a string path literal as the first argument, and an Interop\Http\Server\MiddlewareInterface instance for the second argument. Alternately, use the Zend\Stratigility\path() utility function to generate the instance: path('/foo', $middleware).

      This decorator class replaces usage of the $path argument to MiddlewarePipe::pipe(), and should be used to ensure your application is forwards-compatible with the upcoming version 3 release.

    Changed

    • Nothing.

    Deprecated

    • #140 deprecates the class Zend\Stratigility\Route. This class is an internal detail, and will be removed in version 3.0.0.

    • #140 deprecates the class Zend\Stratigility\Exception\InvalidMiddlewareException. This class will be removed in version 3.0.0 as it will no longer be necessary due to typehint usage.

    • #140 deprecates the class Zend\Stratigility\Exception\InvalidRequestTypeException as it is no longer used by the package. It will be removed in version 3.0.0.

    • #140 deprecates the class Zend\Stratigility\Middleware\CallableInteropMiddlewareWrapper as it is based on interfaces that will no longer be used starting in version 3.0.0. It will be removed in version 3.0.0. Please use the new class Zend\Stratigility\Middleware\CallableMiddlewareDecorator, or the utility function middleware(), to decorate callable standards-signature middleware.

    • #140 deprecates the class Zend\Stratigility\Middleware\CallableMiddlewareWrapper as it is based on interfaces that will no longer be used starting in version 3.0.0. It will be removed in version 3.0.0. Please use the new class Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator, or the utility function doublePassMiddleware(), to decorate callable double pass middleware.

    • #140 deprecates the class Zend\Stratigility\Middleware\CallableMiddlewareWrapperFactory as the class it is associated will be removed starting in version 3.0.0. The class will be removed in version 3.0.0.

    • #140 deprecates the class Zend\Stratigility\NoopFinalHandler as the class will be removed starting in version 3.0.0.

    • #140 deprecates the two-argument form of Zend\Stratigility\MiddlewarePipe::pipe(). If you need to perform path segregation, use the Zend\Stratigility\Middleware\PathMiddlewareDecorator class and/or the Zend\Stratigility\path() function to decorate your middleware in order to provide path segregation.

    • #140 deprecates the piping of double pass middleware directly to pipe(); decorate your double-pass middleware using Zend\Stratigility\Middleware\DoublePassMiddleware or Zend\Stratigility\doublePassMiddleware() prior to piping.

    • #159 deprecates Zend\Stratigility\MiddlewarePipe::setCallableMiddlewareDecorator(). Use Zend\Stratigility\doublePassMiddleware() or Zend\Stratigility\Middleware\DoublePassMiddleware prior to passing your double-pass middleware to MiddlewarePipe::pipe().

    • #159 deprecates Zend\Stratigility\MiddlewarePipe::setResponsePrototype(). This was used only to seed an instance of Zend\Stratigility\Middleware\CallableMiddlewareWrapperFactory previously; pass your response prototype directly to a new instance of Zend\Stratigility\Middleware\DoublePassMiddleware or the ``Zend\Stratigility\doublePassMiddleware()` function instead.

    • #159 deprecates Zend\Stratigility\MiddlewarePipe::hasResponsePrototype().

    Removed

    • Nothing.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 2.2.0rc3(Mar 8, 2018)

    Added

    • Nothing.

    Changed

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • Fixes the signature of PathRequestHandlerDecorator::process() to typehint against the PSR-7 ServerRequestInterface, and not RequestInterface.
    Source code(tar.gz)
    Source code(zip)
  • 2.2.0rc2(Mar 8, 2018)

    Added

    • Nothing.

    Changed

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #160 fixes the implementation of PathRequestHandlerDecorator to implement the process() method, which is defined in the DelegateInterface of http-interop 0.4.1. Without this patch, the class would not work with that version of http-interop.
    Source code(tar.gz)
    Source code(zip)
  • 2.2.0rc1(Mar 6, 2018)

    Added

    • #140 adds the class Zend\Stratigility\Middleware\CallableMiddlewareDecorator for the purpose of decorating callable, standards-signature middleware for use with a MiddlewarePipe instance. Instantiate it directly, passing the callable middleware as the sole argument, or use the Zend\Stratigility\middleware() utility function to generate the instance: middleware($callable).

    • #140 adds the class Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator for the purpose of decorating callable, double-pass middleware for use with a MiddlewarePipe instance. Instantiate it directly, passing the callable middleware and a response instance as arguments, or use the Zend\Stratigility\doublePassMiddleware() utility function to generate the instance: doublePassMiddleware($callable, $response).

    • #140 adds the class Zend\Stratigility\Middleware\PathMiddlewareDecorator for the purposes of creating path-segregated middleware. The constructor expects a string path literal as the first argument, and an Interop\Http\Server\MiddlewareInterface instance for the second argument. Alternately, use the Zend\Stratigility\path() utility function to generate the instance: path('/foo', $middleware).

      This decorator class replaces usage of the $path argument to MiddlewarePipe::pipe(), and should be used to ensure your application is forwards-compatible with the upcoming version 3 release.

    Changed

    • Nothing.

    Deprecated

    • #140 deprecates the class Zend\Stratigility\Route. This class is an internal detail, and will be removed in version 3.0.0.

    • #140 deprecates the class Zend\Stratigility\Exception\InvalidMiddlewareException. This class will be removed in version 3.0.0 as it will no longer be necessary due to typehint usage.

    • #140 deprecates the class Zend\Stratigility\Exception\InvalidRequestTypeException as it is no longer used by the package. It will be removed in version 3.0.0.

    • #140 deprecates the class Zend\Stratigility\Middleware\CallableInteropMiddlewareWrapper as it is based on interfaces that will no longer be used starting in version 3.0.0. It will be removed in version 3.0.0. Please use the new class Zend\Stratigility\Middleware\CallableMiddlewareDecorator, or the utility function middleware(), to decorate callable standards-signature middleware.

    • #140 deprecates the class Zend\Stratigility\Middleware\CallableMiddlewareWrapper as it is based on interfaces that will no longer be used starting in version 3.0.0. It will be removed in version 3.0.0. Please use the new class Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator, or the utility function doublePassMiddleware(), to decorate callable double pass middleware.

    • #140 deprecates the class Zend\Stratigility\Middleware\CallableMiddlewareWrapperFactory as the class it is associated will be removed starting in version 3.0.0. The class will be removed in version 3.0.0.

    • #140 deprecates the class Zend\Stratigility\NoopFinalHandler as the class will be removed starting in version 3.0.0.

    • #140 deprecates the two-argument form of Zend\Stratigility\MiddlewarePipe::pipe(). If you need to perform path segregation, use the Zend\Stratigility\Middleware\PathMiddlewareDecorator class and/or the Zend\Stratigility\path() function to decorate your middleware in order to provide path segregation.

    • #140 deprecates the piping of double pass middleware directly to pipe(); decorate your double-pass middleware using Zend\Stratigility\Middleware\DoublePassMiddleware or Zend\Stratigility\doublePassMiddleware() prior to piping.

    • #159 deprecates Zend\Stratigility\MiddlewarePipe::setCallableMiddlewareDecorator(). Use Zend\Stratigility\doublePassMiddleware() or Zend\Stratigility\Middleware\DoublePassMiddleware prior to passing your double-pass middleware to MiddlewarePipe::pipe().

    • #159 deprecates Zend\Stratigility\MiddlewarePipe::setResponsePrototype(). This was used only to seed an instance of Zend\Stratigility\Middleware\CallableMiddlewareWrapperFactory previously; pass your response prototype directly to a new instance of Zend\Stratigility\Middleware\DoublePassMiddleware or the ``Zend\Stratigility\doublePassMiddleware()` function instead.

    • #159 deprecates Zend\Stratigility\MiddlewarePipe::hasResponsePrototype().

    Removed

    • Nothing.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0rc1(Feb 26, 2018)

    Added

    • Nothing.

    Changed

    • #155 modifies each of the following classes to mark them final:

      • Zend\Stratigility\Middleware\CallableMiddlewareDecorator
      • Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator
      • Zend\Stratigility\Middleware\HostMiddlewareDecorator
      • Zend\Stratigility\Middleware\NotFoundHandler
      • Zend\Stratigility\Middleware\OriginalMessages
      • Zend\Stratigility\Middleware\PathMiddlewareDecorator
      • Zend\Stratigility\Middleware\RequestHandlerMiddleware
      • Zend\Stratigility\Next
    • #157 marks the package as conflicting with zendframework/zend-diactoros versions less than 1.7.1. This is due to the fact that that version provides a bugfix for its Uri::getHost() implementation that ensures it follows the PSR-7 and IETF RFC 3986 specifications.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0alpha4(Feb 22, 2018)

    Added

    • Nothing.

    Changed

    • #153 modifies the first argument of the Zend\Expressive\Middleware\ErrorHandler and NotFoundHandler classes. Previously, they each expected a Psr\Http\Message\ResponseInterface instance; they now both expect a PHP callable capable of producing such an instance. This change was done to simplify re-use of a service for producing unique response instances within dependency injection containers.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0alpha3(Feb 5, 2018)

    Added

    • #150 adds a new class, Zend\Stratigility\Middleware\RequestHandlerMiddleware. The class implements the PSR-15 RequestHandlerInterface and MiddlewareInterface, and accepts a single constructor argument, a RequestHandlerInterface instance. Each of its handle() and process() methods proxy to the composed request handler's handle() method, returning its result.

      This class can be useful for adapting request handlers to use within pipelines.

    Changed

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0alpha2(Jan 25, 2018)

    Added

    • #146 adds a new interface, Zend\Stratigility\MiddlewarePipeInterface. It extends the PSR-15 MiddlewareInterface and RequestHandlerInterface, and defines one additional method, pipe(MiddlewareInterface $middleware) : void.

    • #142 adds a new class, Zend\Stratigility\Middleware\HostMiddlewareDecorator, which provides host segregation functionality for middleware, allowing conditional execution of middleware only if the requested host matches a configured host.

      // Only process $middleware if the request host matches 'example.com':
      $pipeline->pipe(new HostMiddlewareDecorator('example.com', $middleware));
      

      Additionally, the patch provides a utility function, Zend\Stratigility\host(), to simplify the above declaration:

      $pipeline->pipe(host('example.com', $middleware));
      
    • #134 adds a new class, Zend\Stratigility\Middleware\PathMiddlewareDecorator, which provides path segregation functionality for middleware, replacing the functionality that was previously implemented in MiddlewarePipe and Next. Middleware decorated in a PathMiddlewareDecorator will only be processed if the current request URI path matches the path prefix provided to the decorator; if it does match, the request passed to it will strip the path prefix from the URI.

      // Only process $middleware if the request path matches '/foo':
      $pipeline->pipe(new PathMiddlewareDecorator('/foo', $middleware));
      

      Additionally, the patch provides a utility function, Zend\Stratigility\path(), to simplify the above declaration:

      $pipeline->pipe(path('/foo', $middleware));
      
    • #136 adds the utility function Zend\Stratigility\middleware; this function will decorate callable middleware following the PSR-15 signature within a Zend\Stratigility\Middleware\CallableMiddlewareDecorator instance:

      $pipeline->pipe(middleware(function ($request, $handler) {
      });
      
    • #136 adds the utility function Zend\Stratigility\doublePassMiddleware; this function will decorate callable middleware following the double-pass signature within a Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator instance:

      $pipeline->pipe(doublePassMiddleware(function ($request, $response, $next) {
      });
      

    Changed

    • #145 updates the component to implement and consume ONLY PSR-15 interfaces; http-interop interfaces and callable middleware are no longer directly supported (though Stratigility provides decorators for the latter in order to cast them to PSR-15 implementations).

    • #134 and #146 modify MiddlewarePipe in two ways: it now implements the new MiddlewarePipeInterface, and is marked as final, disallowing direct extension. Either decorate an instance in a custom MiddlewarePipeInterface implementation, or create a custom PSR-15 MiddlewareInterface implementation if piping is not necessary or will allow additional types.

    • #134, #145, and #146 update MiddlewarePipe to implement Psr\Http\Server\RequestHandlerInterface. Calling it will cause it to pull the first middleware off the queue and create a Next implementation that uses the remaining queue as the request handler; it then processes the middleware.

    • #134 removes the ability to specify a path when calling pipe(); use the new PathMiddlewareDecorator or path() utility function to pipe middleware with path segregation.

    Deprecated

    • Nothing.

    Removed

    • #134 removes the class Zend\Stratigility\Route. This was an internal message passed between a MiddlewarePipe and Next instance, and its removal should not affect end users.

    • #134 removes Zend\Stratigility\Exception\InvalidMiddlewareException, as the exception is no longer raised by MiddlewarePipe.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0alpha1(Jan 10, 2018)

    Added

    • #124 adds the following classes for decorating callable middleware:

      • Zend\Stratigility\Middleware\CallableMiddlewareDecorator can decorate PHP callables that have a signature the same as or compatible to the PSR-15 MiddlewareInterface.

      • Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator can decorate PHP callables of the form function ($request, $response, $next) as PSR-15 MiddlewareInterface implementations. The class accepts an optional second constructor argument, a ResponseInterface, for providing a response prototype; if none is provided, it will create a zend-diactoros Response instance internally.

    • #128 adds a marker interface, Zend\Stratigility\Exception\ExceptionInterface; all package exceptions now implement this interface, allowing you to catch all package-related exceptions by typehinting against it.

    Changed

    • #122 updates the library to use http-interop/http-server-middleware instead of http-interop/http-middleware, and implement and typehint against the new package's interfaces.

    Deprecated

    • Nothing.

    Removed

    • #122 removes support for PHP versions 5.6, 7.0, as well as HHVM.

    • #122 removes the following classes:

      • Zend\Stratigility\Delegate\CallableDelegateDecorator
      • Zend\Stratigility\Exception\InvalidRequestTypeException
      • Zend\Stratigility\Exception\MissingResponsePrototypeException
      • Zend\Stratigility\MiddlewareInterface
      • Zend\Stratigility\Middleware\CallableInteropMiddlewareWrapper
      • Zend\Stratigility\Middleware\CallableMiddlewareWrapper
      • Zend\Stratigility\Middleware\CallableMiddlewareWrapperFactory
      • Zend\Stratigility\NoopFinalHandler

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 2.1.2(Oct 12, 2017)

    Added

    • Nothing.

    Changed

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #119 updates to webimpress/http-middleware-compatibility ^0.1.3. This was done to ensure backwards compatibilty by injecting the project composer.json with the currently installed version of http-interop/http-middleware, and in cases where that package is not yet installed, prompting the user to install it. This approach provides a tiered migration path to http-middleware 0.5.0 for users.
    Source code(tar.gz)
    Source code(zip)
  • 2.1.1(Oct 10, 2017)

    Added

    • Nothing.

    Changed

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #118 fixes how the MiddlewarePipe detects if the second parameter of callable middleware is a delegate/request handler when choosing whether or not to decorate it to ensure that it will properly decorate it when used with http-interop/http-middleware 0.5.0
    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Oct 9, 2017)

    Added

    • #112 adds support for http-interop/http-middleware 0.5.0 via a polyfill provided by the package webimpress/http-middleware-compatibility. Essentially, this means you can drop this package into an application targeting either the 0.4.1 or 0.5.0 versions of http-middleware, and it will "just work".

    • Adds support for PHP 7.2.

    Changed

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Removes support for HHVM.

    • #107 removes the unused $raiseThrowables property from Zend\Stratigility\Next.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.1(Jan 25, 2017)

    Added

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #98 fixes how Middleware::pipe() handles MiddlewarePipe instances passed to it; previously it was incorrectly wrapping them in CallableMiddlewareWrapper instances; it now pipes them as-is.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Jan 24, 2017)

    Added

    • Nothing.

    Changed

    • #96 changes the minimum supported http-interop/http-middleware version to 0.4.1. This impacts several things:

      • Middleware that implemented the http-interop/http-middleware 0.2.0 interfaces will no longer work with Stratigility. In most cases, these can be updated by changing import statements. As an example:

        // http-middleware 0.2.0:
        use Interop\Http\Middleware\DelegateInterface;
        use Interop\Http\Middleware\ServerMiddlewareInterface;
        
        // Becomes the following under 0.4.1:
        use Interop\Http\ServerMiddleware\DelegateInterface;
        use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface;
        
      • The various classes under Zend\Stratigility\Middleware now implement the new interfaces, which could affect extending classes.

      • Zend\Stratigility\Next and Zend\Stratigility\Delegate\CallableDelegateDecorator have signature changes due to changes in the DelegateInterface; again, these changes should only affect those extending the classes.

      • Interop\Http\Middleware\MiddlewareInterface (which was intended for implementation by client-side middleware) no longer exists, which means it is also no longer supported within Stratigility.

    • #67 updates each of Zend\Stratigility\MiddlewarePipe, Zend\Stratigility\Middleware\ErrorHandler, and Zend\Stratigility\Middleware\NotFoundHandler to require all arguments (none are optional).

    • #67 modifies the internals of Zend\Stratigility\MiddlewarePipe's __invoke() method.

      • When instantiating the Next instance, it now captures it in a variable named $layer.
      • If the result of Next is not a response instance, the response passed during invocation is promoted as the layer response.
      • The response is then passed to the $next argument provided at invocation, and the result of that returned without verification.

      In most cases, this should have no impact on your application.

    • #71 modifies Zend\Stratigility\MiddlewarePipe such that it no longer decorates the request and response provided at invocation with the Zend\Stratigility\Http\* variants, as these have been removed.

    • #76 updates MiddlewarePipe to implement only the http-interop/http-middleware server-side middleware interface, and not the Stratigility-specific MiddlewareInterface (which was removed).

    • #76 updates Zend\Stratigility\Middleware\ErrorHandler to implement the http-interop/http-middleware server-side middleware interface instead of the Stratigility-specific MiddlewareInterface (which was removed).

    • #76 updates Zend\Stratigility\Middleware\NotFoundHandler to implement the http-interop/http-middleware server-side middleware interface instead of the Stratigility-specific MiddlewareInterface (which was removed).

    • #76 updates MiddlewarePipe::__invoke() to require a third argument, now named $delegate, and no longer type-hinted. If a callable not implementing http-interop/http-middleware DelegateInterface is provided, it is wrapped in the CallableDelegateDecorator (introduced in 1.3.0). The method then calls its own process() method with the request and delegate. This method should typically only be used as an entry point for an application.

    • #76 updates MiddlewarePipe::pipe() to raise an exception if callable middleware using the legacy double-pass signature is provided, but no response prototype is composed in the MiddlewarePipe instance yet.

    • #76 updates the constructor of Next to rename the $done argument to $nextDelegate and typehint it against the http-interop/http-middleware DelegateInterface.

    • #76 updates Next::__invoke() to remove all arguments except the $request argument; the method now proxies to the instance process() method.

    • #76 updates Next to no longer compose a Dispatch instance; it is now capable of dispatching on its own.

    • #76 updates the Zend\Stratigility\Route constructor to raise an exception if non-http-interop middleware is provided as the route handler.

    • #79 updates the raiseThrowables() method of each of MiddlewarePipe and Next to be no-ops.

    Deprecated

    • #79 deprecates the raiseThrowables() method of each of MiddlewarePipe and Next.

    Removed

    • Zend\Stratigility\Exception\MiddlewareException was removed as it is no longer thrown.
    • #67 removes Zend\Stratigility\FinalHandler. Use Zend\Stratigility\NoopFinalHandler instead, along with Zend\Stratigility\Middleware\ErrorHandler and Zend\Stratigility\Middleware\NotFoundHandler (or equivalents).
    • #67 removes Zend\Stratigility\ErrorMiddlewareInterface. Register middleware, such as Zend\Stratigility\Middleware\ErrorHandler, in outer layers of your application to handle errors.
    • #67 removes Zend\Stratigility\Dispatch. This was an internal detail of the Next implementation, and should not affect most applications.
    • #67 removes Zend\Stratigility\Utils::getArity(). This was used only in Dispatch; since middleware signatures no longer vary, it is no longer necessary.
    • #67 removes the final, optional $err argument to Zend\Stratigility\Next(); raise exceptions instead, and provide error handling middleware such as Zend\Stratigility\Middleware\ErrorHandler instead.
    • #67 removes the $done argument to the Zend\Stratigility\Next constructor.
    • #71 removes the Zend\Stratigility\Http\Request class.
    • #71 removes the Zend\Stratigility\Http\Response class.
    • #71 removes Zend\Stratigility\Http\ResponseInterface.
    • #76 removes Zend\Stratigility\MiddlewareInterface and Zend\Stratigility\ErrorMiddlewareInterface. The latter is removed entirely, while the former is essentially replaced by http-interop's ServerMiddlewareInterface. You may still write callable middleware using the legacy double-pass signature, however.
    • #76 removes the Zend\Stratigility\Dispatch class. The class was an internal detail of Next, and no longer required.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 1.3.3(Jan 23, 2017)

    Added

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #86 fixes the links to documentation in several exception messages to ensure they will be useful to developers.
    Source code(tar.gz)
    Source code(zip)
  • 1.3.2(Jan 5, 2017)

    Added

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #95 fixes an issue with how the $err is dealt with. Specifically, if an error arises, then subsequent middlewares should be dispatched as callables. Without this fix, stratigility would simply continue dispatching middlewares, ignoring the failing ones.
    Source code(tar.gz)
    Source code(zip)
  • 1.3.1(Nov 11, 2016)

    Added

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #85 fixes an issue with how the $done or $nextDelegate is invoked by Next when an error is present. Previously, the class was detecting a Next instance as an http-interop DelegateInterface instance and dropping the error; this would then mean if the instance contained error middleware, it would never be dispatched.
    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Nov 10, 2016)

    Added

    • #66 adds a new class, Zend\Stratigility\Middleware\NotFoundHandler. This class may be piped into an application at an innermost layer; when invoked, it will return a 404 plain text response.

    • #66 adds a new class, Zend\Stratigility\Middleware\ErrorHandler. This class may be piped into an application, typically at the outermost or one of the outermost layers. When invoked, it does the following:

      • Creates a PHP error handler that will re-throw PHP errors as ErrorExceptions.
      • Dispatches to the next layer.
      • If the next layer does not return a response, it raises a new MissingResponseException.
      • Catches all exceptions from calling the next layer, and passes them to an error response generator to return an error response.

      A default error response generator is provided, which will return a 5XX series response in plain text. You may provide a callable generator to the constructor in order to customize the response generated; please refer to the documentation for details.

    • #66 adds a new class, Zend\Stratigility\NoopFinalHandler. This class may be provided as the $out argument to a MiddlewarePipe, or as the final handler to Zend\Diactoros\Server::listen() (in which case it will be passed to the middleware you invoke as the application). This handler returns the response provided to it verbatim.

    • #70 adds a new class, Zend\Stratigility\Middleware\OriginalMessages. Compose this middleware in an outermost layer, and it will inject the following attributes in the request passed to nested layers:

      • originalRequest, representing the request provided to it.
      • originalResponse, representing the response provided to it.
      • originalUri, representing URI instance composed in the request provided to it.
    • #75 adds support for http-interop middleware 0.2.0. For full details, see the migration guide.

      As a summary of features:

      • You may now pipe http-interop middleware to MiddlewarePipe instances.
      • You may now pipe callable middleware that defines the same signature as http-interop middleware to MiddlewarePipe instances; these will be decorated in a Zend\Stratigility\Middleware\CallableInteropMiddlewareWrapper instance.
      • MiddlewarePipe now implements the http-interop ServerMiddlewareInterface, allowing it to be used in http-interop middleware dispatchers.
    • #75 adds the class Zend\Stratigility\Middleware\CallableMiddlewareWrapper. It accepts callable double-pass middleware and a response prototype, and implements the http-interop ServerMiddlewareInterface, allowing you to adapt existing callable middleware to work with http-interop middleware dispatchers.

    • #75 adds the class Zend\Stratigility\Middleware\CallableInteropMiddlewareWrapper. It accepts callable middleware that follows the http-interop ServerMiddlewareInterface, and implements that interface itself, to allow composing such middleware in http-interop middleware dispatchers.

    • #75 adds the class Zend\Stratigility\Delegate\CallableDelegateDecorator, which can be used to add http-interop middleware support to your existing callable middleware.

    • #75 adds a new method to MiddlewarePipe, setResponseProtoype(). When this method is invoked with a PSR-7 response, the following occurs:

      • That response is injected in Next and Dispatch instances, to allow dispatching legacy callable middleware as if it were http-interop middleware.
      • Any callable middleware implementing the legacy signature will now be decorated using the above CallableMiddlewareWrapper in order to adapt it as http-interop middleware.
    • #78 adds a new method to each of Zend\Stratigility\MiddlewarePipe, Next, and Dispatch: raiseThrowables(). When called, Dispatch will no longer wrap dispatch of middleware in a try/catch block, allowing throwables/exceptions to bubble out. This enables the ability to create error handling middleware as an outer layer or your application instead of relying on error middleware and/or the final handler. Typical usage will be to call the method on the MiddlewarePipe before dispatching it.

    Changed

    • #70 makes the following changes to Zend\Stratigility\FinalHandler:
      • It now pulls the original request using the originalRequest attribute, instead of getOriginalRequest(); see the deprecation of Zend\Stratigility\Http\Request, below, for why this works.
      • It no longer writes to the response using the Zend\Stratigility\Http\Response-specific write() method, but rather pulls the message body and writes to that.
    • #75 updates MiddlewarePipe to inject the $response argument to __invoke() as the response prototype.
    • #75 updates Zend\Stratigility\Next to implement the http-interop middleware DelegateInterface. It also updates Zend\Stratigility\Dispatch to add a new method, process(), following the DelegateInterface signature, thus allowing Next to properly process http-interop middleware. These methods will use the composed response prototype, if present, to invoke callable middleware using the legacy signature.
    • #75 updates Next to allow the $done constructor argument to be an http-interop DelegateInterface, and will invoke it as such if the queue is exhausted.
    • #75 updates Route (which is used internally by MiddlewarePipe to allow either callable or http-interop middleware as route handlers.

    Deprecated

    • #66 deprecates the Zend\Stratigility\FinalHandler class. We now recommend using the NoopFinalHandler, along with the ErrorHandler and NotFoundHandler middleware (or equivalents) to provide a more fine-grained, flexible, error handling solution for your applications.
    • #66 deprecates the Zend\Stratigility\Dispatch class. This class is used internally by Next, and deprecation should not affect the majority of users.
    • #66 deprecates Zend\Stratigility\ErrorMiddlewareInterface. We recommend instead using exceptions, along with the ErrorHandler, to provide error handling for your application.
    • #66 updates Zend\Stratigility\MiddlewarePipe::__invoke() to emit a deprecation notice if no $out argument is provided, as version 2 will require it.
    • #66 updates Zend\Stratigility\Next::__invoke() to emit a deprecation notice if a non-null $err argument is provided; middleware should raise an exception, instead of invoking middleware implementing ErrorMiddlewareInterface.
    • #70 deprecates Zend\Stratigility\Http\Request. Additionally:
      • The composed "PSR Request" is now injected with an additional attribute, originalRequest, allowing retrieval using standard PSR-7 attribute access.
      • The methods getCurrentRequest() and getOriginalRequest() now emit deprecation notices when invoked, urging users to update their code.
    • #70 deprecates Zend\Stratigility\Http\ResponseInterface.
    • #70 deprecates Zend\Stratigility\Http\Response. Additionally, the methods write(), end(), isComplete(), and getOriginalResponse() now emit deprecation notices when invoked, urging users to update their code.
    • #75 deprecates the $response argument in existing callable middleware. Please only operate on the response returned by $next/$delegate, or create a response. See the documentation section on response arguments for more details.
    • #75 deprecates usage of error middleware, and thus deprecates the $err argument to $next; explicitly invoking error middleware using that argument to $next will now raise a deprecation notice.

    Removed

    • Nothing.

    Fixed

    • Nothing.
    Source code(tar.gz)
    Source code(zip)
  • 1.2.1(Mar 24, 2016)

    Added

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #52 fixes the behavior of the FinalHandler with regards to exception handling, ensuring that the reason phrase reported corresponds to the HTTP status code used.
    • #54 modifies the behavior of the FinalHandler when creating an error or 404 response to call write() instead of end() on the response object. This fixes a lingering issue with emitting the Content-Length header from the SapiEmitter, as well as prevents the SapiEmitter from raising exceptions when doing so (which was happening starting with 1.2.0).
    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Mar 17, 2016)

    This release contains two potential backwards compatibility breaks:

    • In versions prior to 1.2.0, after Zend\Stratigility\Http\Response::end() was called, with*() operations were performed as no-ops, which led to hard-to-detect errors. Starting with 1.2.0, they now raise a RuntimeException.
    • In versions prior to 1.2.0, Zend\Stratigility\FinalHandler always provided exception details in the response payload for errors. Starting with 1.2.0, it only does so if not in a production environment (which is the default environment).

    Added

    • #36 adds a new InvalidMiddlewareException, with the static factory fromValue() that provides an exception message detailing the invalid type. MiddlewarePipe now throws this exception from the pipe() method when a non-callable value is provided.
    • #46 adds FinalHandler::setOriginalResponse(), allowing you to alter the response used for comparisons when the FinalHandler is invoked.
    • #37 and #49 add support in Zend\Stratigility\Dispatch to catch PHP 7 Throwables.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #30 updates the Response implementation to raise exceptions from with*() methods if they are called after end().
    • #46 fixes the behavior of FinalHandler::handleError() to only display exception details when not in production environments, and changes the default environment to production.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.3(Mar 17, 2016)

    Added

    • Nothing.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #39 updates the FinalHandler to ensure that emitted exception messages include previous exceptions.
    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Jun 25, 2015)

    Added

    • #13 adds Utils::getStatusCode($error, ResponseInterface $response); this static method will attempt to use an exception code as an HTTP status code, if it falls in a valid HTTP error status range. If the error is not an exception, it ensures that the status code is an error status.

    Deprecated

    • Nothing.

    Removed

    • Nothing.

    Fixed

    • #12 updates FinalHandler such that it will return the response provided at invocation if it differs from the response at initialization (i.e., a new response instance, or if the body size has changed). This allows you to safely call $next() from all middleware in order to allow post-processing.
    Source code(tar.gz)
    Source code(zip)
Owner
Zend Framework
Zend Framework
PSR-15 middleware for Symfony framework.

PSR-15 middleware now in Symfony Contents Installation Configuration Usage Examples Customization Caching Real World Example Middlewares Testing Licen

kafkiansky 60 Dec 14, 2022
Slim Framework 2 middleware

Slim Framework Middleware This repository contains a library of optional middleware for your Slim Framework application. How to Install Update your co

Slim Framework 47 Nov 7, 2022
[DEPRECATED] Collection of PSR-7 middlewares

This package is deprecated in favor of the new PSR-15 standard. Check it out here psr7-middlewares Collection of PSR-7 middlewares. Requirements PHP >

Oscar Otero 669 Dec 27, 2022
A PSR-15 server request handler.

Relay A PSR-15 request handler. This package is installable and PSR-4 autoloadable via Composer as "relay/relay": "~2.0". Alternatively, download a re

Relay 304 Dec 30, 2022
Fast PSR-7 based routing and dispatch component including PSR-15 middleware, built on top of FastRoute.

Route This package is compliant with PSR-1, PSR-2, PSR-4, PSR-7, PSR-11 and PSR-15. If you notice compliance oversights, please send a patch via pull

The League of Extraordinary Packages 608 Dec 30, 2022
A simple and flexible PHP middleware dispatcher based on PSR-7, PSR-11, and PSR-15

Woohoo Labs. Harmony Woohoo Labs. Harmony is a PSR-15 compatible middleware dispatcher. Harmony was born to be a totally flexible and almost invisible

Woohoo Labs. 153 Sep 5, 2022
PSR-7 middleware foundation for building and dispatching middleware pipelines

laminas-stratigility From "Strata", Latin for "layer", and "agility". This package supersedes and replaces phly/conduit. Stratigility is a port of Sen

Laminas Project 47 Dec 22, 2022
PSR-7 and PSR-15 JWT Authentication Middleware

PSR-7 and PSR-15 JWT Authentication Middleware This middleware implements JSON Web Token Authentication. It was originally developed for Slim but can

Mika Tuupola 782 Dec 18, 2022
PSR-7 and PSR-15 HTTP Basic Authentication Middleware

PSR-7 and PSR-15 Basic Auth Middleware This middleware implements HTTP Basic Authentication. It was originally developed for Slim but can be used with

Mika Tuupola 430 Dec 30, 2022
A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.

Net A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package. Features: No hard dependencies; Favours

Minibase 16 Jun 7, 2022
A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.

Net A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package. Features: No hard dependencies; Favours

Minibase 16 Jun 7, 2022
UserFrosting is a secure, modern user management system written in PHP and built on top of the Slim Microframework, Twig templating engine, and Eloquent ORM.

UserFrosting is a secure, modern user management system written in PHP and built on top of the Slim Microframework, Twig templating engine, and Eloquent ORM.

UserFrosting 1.6k Jan 1, 2023
UserFrosting is a secure, modern user management system written in PHP and built on top of the Slim Microframework, Twig templating engine, and Eloquent ORM.

UserFrosting 4.6 Branch Version Build Coverage Style master hotfix develop https://www.userfrosting.com If you simply want to show that you like this

UserFrosting 1.6k Jan 1, 2023
Kyle is a web application built with Laravel for web developers and small companies to efficiently track and stay on top of yearly expenses related to services

Kyle Kyle is a web application built with Laravel for web developers and small companies to efficiently track and stay on top of yearly expenses relat

Laravelista 36 Jul 15, 2022
A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL.

grifart/tables A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL. This library is develope

GRIFART 5 Nov 11, 2022
PHP cache library, with adapters for e.g. Memcached, Redis, Couchbase, APC(u), SQL and additional capabilities (e.g. transactions, stampede protection) built on top.

Donate/Support: Documentation: https://www.scrapbook.cash - API reference: https://docs.scrapbook.cash Table of contents Installation & usage Adapters

Matthias Mullie 295 Nov 28, 2022
A PHP 5.3 CMS built on top of Laravel 4 and other composer components.

Anvil Forge your website! A PHP 5.3 CMS built on top of Laravel 4 and other composer components. Installation Installing Anvil is easy. Run the follow

Loïc Sharma 17 May 3, 2022
Tiny, fast and simple PHP boilerplate built on top of FlightPHP

BlessPHP Tiny, fast and simple PHP boilerplate built on top of FlightPHP. Good enough to use as skeleton for prototypes and some pet-projects. The nam

Anthony Axenov 2 Sep 20, 2022
Simple async lowlevel ICMP (ping) messaging library built on top of React PHP

clue/icmp-react Simple async lowlevel ICMP (ping) messaging library built on top of react Usage Once clue/icmp-react is installed, you can run any of

Christian Lück 13 Jun 10, 2022
FrankenPHP is a modern application server for PHP built on top of the Caddy web server

FrankenPHP: Modern App Server for PHP FrankenPHP is a modern application server for PHP built on top of the Caddy web server. FrankenPHP gives superpo

Kévin Dunglas 2.8k Jan 2, 2023