News Feed
Sections




News Archive
feed this:

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

PHP Roundtable:
022 All About PSR-7
June 12, 2015 @ 10:21:00

The PHP RoundTable podcast has posted their latest episode - Episode #22: All About PSR-7 (the recently accepted PHP-FIG standard for an HTTP interface layer).

PSR-7 is the latest accepted member to the PHP FIG's standards library. We discuss what PSR-7 is, how it utilizes streams, immutability & middleware, and how it will affects you as a developer.

You can catch this latest episode either through the embedded video player or directly on YouTube. If you enjoy the show, be sure to subscribe to their feed or follow them on Twitter.

0 comments voice your opinion now!
phproundtable ep22 psr7 http larrygarfield matthewweierophinney beausimensen

Link: https://www.phproundtable.com/episode/psr-7-streams-immutability-middleware-oh-my

Symfony Blog:
PSR-7 Support in Symfony is Here
June 01, 2015 @ 12:19:15

The Symfony project has officially announced PSR-7 support in the latest version of the framework. PSR-7 is a recently approved standard by the PHP-FIG to make a more structured HTTP request and response structure (to aid in interoperability).

Less than 2 weeks ago, the PHP community roundly accepted PSR-7, giving PHP a common set of HTTP Message Interfaces. This has huge potential for interoperability and standardization across all of PHP. This is especially true for middleware: functions that hook into the request-response process. In the future, a middleware written around these new interfaces could be used in any framework. [...] Today, a huge number of projects use Symfony's Request and Response classes (via the HttpFoundation component), including Laravel, Drupal 8 and StackPHP.

[...] For that reason, we're thrilled to announce the 0.1 release of the PSR HTTP Message Bridge: a library that can convert Symfony Request and Response objects to PSR-7 compatible objects and back. This means that once there are middleware written for PSR-7, applications using HttpFoundation will be compatible.

The bridge makes it simpler to swap out the HTTP layer by converting the HTTP objects into something other frameworks can use (or so others can be used by Symfony). They provide some examples of how to put it to use, converting objects both to and from the standard Symfony HttpFoundation versions. There's also a quick note about the RequestInterface and ResponseInterface structure that allows you to bridge your own gaps between the PSR-7 friendly components and Symfony.

0 comments voice your opinion now!
psr7 support httpfoundation request response http bridge phpfig

Link: http://symfony.com/blog/psr-7-support-in-symfony-is-here

Frank de Jonge:
Rendering ReactJS templates server-side
May 21, 2015 @ 09:17:50

Frank de Jonge has posted a tutorial to his site showing how you can render React.js templates server-side in PHP. He makes use of the V8JS extension to execute Javascript inside of PHP and echo out the rendered result.

The last couple of months I've been working with ReactJS quite extensively. It's been a very rewarding and insightful journey. There is, however, one part that kept coming back to me: server-side rendering. How on earth am I going to use ReactJS when I want to render my templates on the server? So, I sat down and looked at the possibilities.

He suggests two options, running a small Node application or using the V8JS extension, and opts for trying the second option to meet his needs. He talks about the "why" of rendering server-side JS and gives a brief introduction to V8JS and the workflow he'll follow to use it. He helps you get this library via Composer to make working with it easier and provides an example of how to use it. After trying out this method, he then goes back to option #1, the small Node application (what he ended up choosing). He walks through the setup of this application, showing how to set it up inside a Lumen application and using Express to output the generated templates and data. He then hooks this into the PHP application via a simple HTTP client grabbing the results and pushing them back out to the page.

0 comments voice your opinion now!
reactjs template serverside nodejs v8js extension http lumen

Link: http://blog.frankdejonge.nl/rendering-reactjs-templates-server-side/

Marc Morera:
Visithor, Testing Your Routes Without Pain
May 05, 2015 @ 09:25:55

In his latest post Marc Morera shares a new tool he's created to help with testing routes for specific HTTP code responses and other attributes of your "HTTP layer" - Visithor.

Many years ago I was thinking about a simple and fast tool to test specific routes, expecting specific HTTP codes and providing an easy environment of ensuring properly your HTTP layer. So... I present you Visithor, a PHP based library that provides you this functionality, with a simple configuration definition and a very easy way of installation.

He starts with a few quick commands to get the library installed (either globally or local to the project) and how to create the first configuration file. This file defines the tests to execute as a set of URLs with allowed HTTP response codes. He also shares a Symfony2 bundle that can be used to integrate it with your current application, allowing for more flexibility in route check configuration and environment settings. He also includes a quick example of integrating it with your Travis-CI build as a "script" command to be executed.

0 comments voice your opinion now!
visithor library testing http response code symfony2 bundle integration

Link: http://mmoreram.com/blog/2015/05/04/visithor/

Hari KT:
Zend Feed and Guzzle
April 02, 2015 @ 10:43:06

Hari KT has posted some of the results of his work integrating the Guzzle client into the Zend Feed component for use in handling it's HTTP requests and responses.

You may have worked with Zend Feed as a standalone component. I don't know whether you have integrated Zend framework Feed with Guzzle as Http Client. This post is inspired by Matthew Weier O'Phinney, who have mentioned the same on github.

He starts with the contents of his composer.json configuration file, pulling in Guzzle, ZendFeed and ZendService, and explaining the need for each. He then makes a simple "GuzzleClient" class and "GuzzleResponse" class that fit with the needed interfaces used by ZendFeed. Then he "wires them up" and injects the custom client and responses classes into the ZendFeed instance.

0 comments voice your opinion now!
zendfeed component guzzle integrate http client interface tutorial

Link: http://harikt.com/blog/2015/04/01/zend-feed-and-guzzle/

PHP-FIG:
PSR-7 Voting Canceled
April 02, 2015 @ 09:34:40

The voting phase for the PSR-7 proposal (HTTP messaging structure) has been cancelled due to the desire to improve and clarify the spec before approving it.

Since we put PSR-7 up for a vote, a number of issues have arisen that we feel require attention. In most cases these are clarifications that, had they been made during REVIEW, could have been merged without dropping the spec back to DRAFT. Sadly, since PSR-7 is now up for a vote, we cannot make clarifications to the spec. We cannot even make clarifications after the spec is accepted, either, except by way of annotations and errata in the meta document.

We've weighed the risk of leaving the spec as-is against canceling the vote and making the required changes directly to the spec itself. This has been an ongoing discussion since the middle of last week. I had a meeting with Mathew and Paul this morning in which we decided that it would be in the best interest of everyone for us to cancel the vote and make the changes directly.

The call was a tough one, but the discussions around the proposal have worked out a lot of the kinks, just not all of them. As is mentioned in the Google Groups post, the PSR will go back up for a vote in two weeks. PSR-7 outlines a standardized interface for working with HTTP requests and responses, providing interoperability between frameworks and tools at this basic level.

0 comments voice your opinion now!
psr7 http standard http vote cancel rework review

Link: https://groups.google.com/forum/#!msg/php-fig/42WhFKJzgrQ/9YbhKdLEOp4J

Dracony:
Replacing controllers with middleware
April 01, 2015 @ 09:53:50

Dracony has a new post to his site that suggests replacing controllers with middleware and how it relates to some of the current controller practices.

Middleware is now a very popular topic in the PHP community, here are some of my thoughts on the subject. [...] The idea behind it is "wrapping" your application logic with additional request processing logic, and then chaining as much of those wrappers as you like. So when your server receives a request, it would be first processed by your middlewares, and then after you generate a response it will also be processed by the same set.

After giving a few examples of what could be a good fit for use as middleware, he makes the suggestion to replace controllers. He talks about some of the problems that middleware brings with it and how to turn things around and write controllers as middleware (and not wrap them in it). He finishes with a mention of the work being done on PSR-7 (the HTTP Request proposal) and some thoughts on how it could fit into his middleware ideas.

0 comments voice your opinion now!
middleware controller replacement opinion psr7 http

Link: http://dracony.org/replacing-controllers-with-middleware/

Evert Pot:
PSR-7 is imminent, and here's my issues with it.
March 04, 2015 @ 09:26:37

Evert Pot has written up a new post today with some of his thoughts about what's wrong with the PSR-7 proposal in the PHP-FIG. PSR-7 relates to a standardized interface for HTTP request and response handling.

PSR-7 is pretty close to completion. PSR-7 is a new 'PHP standard recommendation', put out by the PHP-FIG group, of which I'm a member of. [...] PSR-7 gets a lot of things right, and is very close to nailing the abstract data model behind HTTP, better than many other implementations in many programming languages.

But it's not perfect. I've been pretty vocal about a few issues I have with the approach. Most of this has fallen on deaf ears. I accept that I might be a minority in feeling these are problems, but I feel compelled to share my issues here anyway. Perhaps as a last attempt to sollicit change, or maybe just to get it off my chest.

He breaks up his thoughts into a few different categories, each with a summary and sometimes some code to help make his point a bit more clear. He talks about immutability, how objects will be immutable and shows an example of change in how Silex would have to function to follow the standard (with before/after). He then goes on to talk about the "issue with streams" and how the current proposal could allow for changing of the incoming request into a new one with new headers...not immutable. He ends the post talking about PSR-7's stance on buffering responses and how, even if his project doesn't adopt the PSR in the strictest sense, they may still take some inspiration from it.

0 comments voice your opinion now!
psr7 issues opinion phpfig http standard request response

Link: http://evertpot.com/psr-7-issues/

Matthew Weier O'Phinney:
PSR-7 By Example
January 29, 2015 @ 09:13:20

As a part of his involvement in the PHP-FIG standards group, Matthew Weier O'Phinney has been contributing to the PSR-7 proposal. This proposal defines a standardized structure for HTTP message handling. In his latest post he gets into a bit more detail on what this means for the PHP developer and how it might be implemented.

PSR-7 is shaping up nicely. I pushed some updates earlier this week, and we tagged 0.6.0 of the http-message package last week for implementors and potential users to start coding against. I'm still hearing some grumbles both of "simplify!" and "not far enough!" so I'm writing this posts to demonstrate usage of the currently published interfaces, and to illustrate both the ease of use and the completeness and robustness they offer.

He starts with a base definition of what the proposal, well, proposes around HTTP messaging, both the incoming and outgoing. He describes the basic structure of an HTTP message and what each part represents. He talks about message headers, bodies and how the current library could return that content. He then looks at requests vs responses, server-side requests and some various uses cases and more practical examples:

  • HTTP Clients
  • Middleware
  • Frameworks

With the PSR-7 standard in place, all of these different tools could have interchangeable interfaces for HTTP request/responses, easily swappable with any other implementation.

0 comments voice your opinion now!
psr7 http message request response summary tool framework middleware client

Link: https://mwop.net/blog/2015-01-26-psr-7-by-example.html

Dave Hulbert:
Thoughts on PSR-7
January 12, 2015 @ 12:51:03

In a new post to his site Dave Hulbert has shared some of his thoughts about the PSR-7 standard, a HTTP proposal for HTTP handling.

PSR-7 contains interfaces for HTTP messages. These are like Symfony Kernel's Request and Response interfaces. Having these new interfaces would be great for the PHP community but there's a couple of issues with their current state that I'm not happy with.

One of PSR-7's goals is "Keep the interfaces as minimal as possible". I think the current interfaces are not minimal enough.

He breaks down his thoughts into a few different sections covering ideas around:

  • Immutability and PSR-7's enforcement of mutability
  • Being too strict to the (HTTP) spec
  • Splitting client and server message interfaces
  • Writing and reading from StreamableInterface

He sums up his thoughts under each section pretty quickly. If you haven't heard much about the PSR-7 proposal and want more context on what he's referencing, check out this proposal (or other posts sharing opinions from other developers).

0 comments voice your opinion now!
opinion psr7 http specification message immutability streamableinterface

Link: http://createopen.com/design/php/2014/12/15/psr-7.html


Community Events

Don't see your event here?
Let us know!


interview api yii2 community part2 introduction voicesoftheelephpant project example podcast opinion laravel php7 framework series composer symfony application language list

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework