The SitePoint PHP blog has a tutorial posted today that wants to help you understand StackPHP, the project centered around middleware, specifically related to the Symfony2 HttpKernelInterface.
Today we are going to look at StackPHP and try to understand what this thing is all about. Although this post will have some code, this article will be rather theoretical as we are interested in learning what StackPHP actually is, where it comes from and why it is useful. As the front page of the StackPHP project says, Stack is a convention for composing HttpKernelInterface middlewares. But, in order to actually understand this definition, we will have to cover a few concepts first. At the end, we will also illustrate the concepts we learned in the context of StackPHP with some example code.
They start with a brief look at the HttpKernelInterface and how it works with the overall request and response flow of a typical application request. From there they describe the Decorator design pattern that will be used to augment the request/response objects as they're going through the middleware process. Following this they look at how StackPHP fits into this picture and provides a few code examples showing both basic and a bit more complex middleware handling (including the use of StackBuilder).
Link: http://www.sitepoint.com/stackphp-explained/
没有评论:
发表评论