StackPHP Explained

Originally published at: http://www.sitepoint.com/stackphp-explained/

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.

StackPHP Logo

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. This usually makes things much easier to understand.

Continue reading this article on SitePoint

In the last part when you demonstrate the pushing to the stack, I get a bit confused by the terminology. You push 3 Kernels to the stack but conclude to push Middlewares. What is right here? As far as I ahve seen it from Laravel 5 you provider Middlewares which are then handled by the Kernel. I could be wrong though.

In “What is the decorator pattern?” part, the example NotifiedAction class could have an error.

NotifiedAction::14 would be
$performed = $this->action->trigger();

Hey there,

In broad strokes, an HTTPKernelInterface implementation is what a Middleware is in this case. So basically any class that respects the StackPHP “rules” (convention) - is a stackable middleware.

Thanks!

Hey there,

Thanks for picking that up. You are completely right :slight_smile:

Cheers!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.