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

Michael Dowling:
Guzzle-Ring and Future Responses
Sep 30, 2014 @ 14:36:32

Michael Dowling has a new post to his site today talking about the work that's being done on the upcoming release of the Guzzle HTTP client. In the post he talks about a major change in how it allows for asynchronous requests and the work on Guzzle-Ring to make it happen.

Guzzle 4 has been out for a little over six months. It has proven to be leaps and bounds better than Guzzle 3, and I’ve been very happy with the design so far. However, after the release of Guzzle 4, I’ve received feedback from numerous members of the PHP community that can be boiled down to “Guzzle needs async support.” While Guzzle has always had the ability to send requests concurrently using a pool of requests, there was not a way to send asynchronous requests.

After a couple months of work and borrowing concepts from Clojure, I’ve created Guzzle-Ring, an extremely simple adapter and middleware library for PHP (not just Guzzle) that can power both clients and servers for both synchronous and asynchronous requests.

The Guzzle-Ring reduces the need for the previous complexity of creating multiple adapters, which ended up with the adapters knowing too much about the request itself. He introduces the Guzzle-Ring system that will be included in Guzzle v5, heavily influenced by Clojure. The adapter makes the request as simple as passing in an array and makes use of "futures" to handle the request/response cycle. He also talks some about creating middleware piece that helps integrate it into your application, wrapping functionality inside of another method. He illustrates all of this with code examples and includes others such as fetching of future responses, sending requests concurrently and the Guzzle-Ring server adapters.

tagged: guzzle guzzlering http client asynchronous request futures guzzle5 clojure

Link: http://mtdowling.com/blog/2014/09/28/guzzle-ring/

Adam Bard:
The Same App 4 Times: PHP vs Python vs Ruby vs Clojure
Mar 27, 2013 @ 14:13:35

Adam Bard has written up a post that takes the same small application (a "Nurblizer") and writes it as a web application in four different languages - PHP, Python, Ruby and Clojure. His point is less about which is "best" but more to show the differences between them.

Here’s a toy program I wrote implemented in PHP, Python, Ruby, and Clojure. I hope it’s helpful for someone who knows at least one of those and wants to learn another. The program is called “Nurblizer”, and it does one thing: Accept free-form text, and attempt to replace all words but the nouns in said text with the word “nurble”. It’s up and running at http://nurblizer.herokuapp.com

He includes the source for each language's version using Sinatra for Ruby and Flask for Python but for PHP and Clojure it's just straight code. For each he briefly explains what its doing and a bit about how it relates to the examples from the other languages. He also points out a Hacker News discussion that's popped up about the examples.

tagged: flask python clojure ruby example nurblizer compare

Link:


Trending Topics: