Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
StackPHP Explained
Apr 23, 2015 @ 16:40:02

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).

tagged: stackphp tutorial middleware httpkernelinterface symfony2 introduction

Link: http://www.sitepoint.com/stackphp-explained/

ServerGrove Blog:
Symfony2 components overview: HttpKernel
Oct 01, 2013 @ 16:25:35

On the ServerGrove blog today they've posted the second in their series focusing on individual components of the Symfony2 framework. In this new post they look at the HttpKernel component, another of the foundational blocks of the framework.

In the second post of the Symfony2 components series we are going to talk about the HttpKernel component. If the HttpFoundation component provided the building blocks of the HTTP protocol, the HttpKernel component makes use of them to define an abstract process for converting a Request into a Response.

The post looks at the HttpKernelInterface, the "front door" to the component that takes in a Request object and makes its contents accessible. Also included is a list of some of the configuration options that can be used to alter its behavior, all based on events that fire during execution (the kernel is driven by events). There's also an example included of using the StackPHP middleware as decorators on the kernel.

tagged: symfony2 component overview httpkernel httpkernelinterface stackphp

Link: http://blog.servergrove.com/2013/09/30/symfony2-components-overview-httpkernel/

Gonzalo Ayuso:
Bundles in Silex using Stack
Jul 17, 2013 @ 16:10:34

Gonzalo Ayuso has a recent post to his site showing you how to use Stack to create bundles for your Silex-based applications. Stack is a structure that allows for the reuse of HttpKernelInterface middleware to create a custom "stack" of functionality.

Nowadays almost every modern framework/applications implements HttpKernelInterface (Symfony, Laravel, Drupal, Silex, Yolo and even the framework that I’m working in ;) ) and we can build complex applications mixing different components and decorate our applications with an elegant syntax. The first thing than come to my mind after studying Stack is to join different Silex applications in a similar way than Symfony (the full stack framework) uses bundles.

In his example, he shows an example of a simple GET endpoint for a blog and API. In the first version, he calls the "run" method to execute the handling of the request. The second example, however, includes the attachment of a simple "MyKernel" middleware to the stack and calls "handle" to apply and send the modified Response back to the user.

tagged: silex stack tutorial introduction middleware httpkernelinterface

Link: http://gonzalo123.com/2013/07/15/bundles-in-silex-using-stack

Igor Wiedler:
Introducing Stack
Jun 04, 2013 @ 17:46:42

Igor Wiedler has started up a new project that helps you combine "stacks" of middleware related to the HttpKernelInterface from Symfony as a sort of decorator to its base functionality - Stack.

In the post titled HttpKernel middlewares I brought up the idea of bringing rack middlewares to Symfony2. In order to solidify this effort I would like to announce a new project: Stack. Stack is a convention for composing HttpKernelInterface middlewares. The name and logo are based on the idea of building a stack of middleware layers, each of which handles a particular piece of logic. [...] The main goal of stack is to give the idea of "HttpKernel middlewares" a name, so that we can more easily talk about it.

There's a stackphp organization on Github that has the start of this set of middleware pieces including tools to help you build other features. The project is focused around the Symfony HttpKernelInterface because it was the simpler, more standardized option for now. He notes that there's no reason that, in the future, when things are more standardized it couldn't broaden out to PHP as a whole.

tagged: symfony httpkernelinterface stack middleware project

Link: https://igor.io/2013/05/23/introducing-stack.html

Fabien Potencier's Blog:
Create your own framework... on top of the Symfony2 Components (part 10)
Jan 23, 2012 @ 16:55:22

Fabien Potencier has posted the tenth part of his series about making a custom framework based on the Symfony2 component set. In this latest article he focuses on using the HttpKernelInterface to add in some additional HTTP-related support.

In the conclusion of the second part of this series, I've talked about one great benefit of using the Symfony2 components: the interoperability between all frameworks and applications using them. Let's do a big step towards this goal by making our framework implement HttpKernelInterface.

By changing up the custom framework just a bit to use HttpKernelInterface, you get built-in HTTP caching (HttpCache). He shows how to use this class to create some custom caching rules and how to use Edge Side Includes to only cache partial parts of the page.

tagged: framework symfony2 custom tutorial series httpkernelinterface httpcache

Link:


Trending Topics: