PHPDeveloper.orghttp://www.phpdeveloper.org
Up-to-the Minute PHP News, views and communityen-usTue, 03 Mar 2015 16:51:27 -060030http://www.phpdeveloper.org/news/20189http://www.phpdeveloper.org/news/20189
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.

Link: http://blog.servergrove.com/2013/09/30/symfony2-components-overview-httpkernel/]]>Tue, 01 Oct 2013 11:25:35 -0500http://www.phpdeveloper.org/news/19861http://www.phpdeveloper.org/news/19861
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.

Link: http://gonzalo123.com/2013/07/15/bundles-in-silex-using-stack]]>Wed, 17 Jul 2013 11:10:34 -0500http://www.phpdeveloper.org/news/19670http://www.phpdeveloper.org/news/19670
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.

Link: https://igor.io/2013/05/23/introducing-stack.html]]>Tue, 04 Jun 2013 12:46:42 -0500http://www.phpdeveloper.org/news/17432http://www.phpdeveloper.org/news/17432
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.