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

Michael Dowling:
Guzzle-Ring and Future Responses
September 30, 2014 @ 09: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.

0 comments voice your opinion now!
guzzle guzzlering http client asynchronous request futures guzzle5 clojure

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

SitePoint PHP Blog:
Unit Testing with GuzzlePHP
May 16, 2014 @ 11:56:46

The SitePoint PHP site has a new tutorial posted today showing how, if you're using the Guzzle PHP HTTP client, to work with it in your unit testing. He focuses on PHPUnit testing, but the concepts could be applied in other testing tools as well.

In this tutorial, I want to show you how to use Guzzle from a different perspective, specifically how to do unit testing with it. To do this, we're going to look at three specific approaches: hand crafting custom responses, using a ServiceClient with mock response files and enqueueing a Server with mock responses.

Matthew helps you get started by installing Guzzle and PHPUnit via Composer, including the "composer.json" contents you'll need. He shows you how to get PHPUnit all set up and how to create a first simple test that extends the "GuzzleTestCase" class. He then gets into the custom hand-crafted responses, showing how to push the contents of a text file into the client response. Next up he shows how to use the ServiceClient to create the same setup only simpler. Finally, he looks at the queue handling (via a small node.js background server) where the client passes requests and is returned the same mock body content. Code examples of both the requests and the PHPUnit tests are included through out the tutorial.

0 comments voice your opinion now!
unittest guzzlephp http client tutorial phpunit

Link: http://www.sitepoint.com/unit-testing-guzzlephp

InfoTuts.com:
Create Login With Google Plus in Your Website With PHP
April 15, 2014 @ 10:20:31

On the InfoTuts.com site they've posted a tutorial showing you how to make a "Log in with Google" button for your application and make it work with a little PHP magic on the backend.

So you want to allow users to login into your website using their gmail credentials? You have seen various websites that allow their users to login in their websites using gmail, facebook, linked in, Microsoft, git hub credentials. It's time to integrate it in your website. We will cover all the login system in our posts one by one and this one is dedicated to create Google Plus login for your website with PHP using OAuth2. Google offers many APIs like Google Maps, translate API, Analytics ApI etc. Today we will use its Google Plus API so lets proceed with our tutorial.

They break the process down into about five steps:

  • Login to Google API Console. Go to APIs and you will have to turn on Google Plus API.
  • Go to APIs and Auth and then under credentials tab. Click on create new client ID as shown below.
  • Now when you will have to enter your website path and the file path (redirect URI) to get your new client ID.
  • Now you have to set Consent screen.
  • In consent screen if you have entered Google Plus page path then you will have to approve connection.

The code for the actual connection is in the last step. It uses Google's PHP client libraries to configure and make the request, fetch the access token and grab the Google+ user's data.

0 comments voice your opinion now!
googleplus login oauth2 client library tutorial

Link: http://www.infotuts.com/login-with-google-plus-in-your-website-php

Michael Dowling:
Guzzle 4.0
March 31, 2014 @ 13:57:08

Michael Dowling has announced the release of Guzzle 4.0.0 on his site today. Guzzle is one of the most widely used, popular HTTP clients in the PHP community today. Its used in both corporate and open source projects as a primary means for making HTTP requests and RESTful web service clients.

Guzzle 4.0 has arrived! The new version of Guzzle is now simpler, faster, more flexible, and more powerful than ever. [...] Guzzle is a PHP HTTP client that makes it easy to work with HTTP/1.1 and takes the pain out of consuming web services.

He includes a quick example of it in use making a request to the GitHub API to fetch user information. He lists out some of the changes made in this release but points to this other post for the full list. He's also tagged other related projects to match this 4.0.0 release including Guzzle Streams and the Log Subscriber.

0 comments voice your opinion now!
guzzle http client restful release v4

Link: http://mtdowling.com/blog/2014/03/29/guzzle4/

SitePoint PHP Blog:
Debugging with Xdebug and Sublime Text 3
February 28, 2014 @ 11:10:53

The latest post from the SitePoint PHP blog, a new tutorial by Peter Nijssen, shows you how to get started with Xdebug and Sublime Text 3 to debug your PHP applications.

Debugging - we all do it a lot. Writing code perfectly the first time around is hard and only a few (if any) succeed at it. More than a year ago, Shameer wrote an article on SitePoint about how you can debug your application using Xdebug and Netbeans. In this article, we are going to have a look at how we can debug using Xdebug in combination with Sublime Text.

He assumes you already have Xdebug installed (and links to the instructions for those that don't) and helps you configure it to find your listening editor. Back in Sublime, he shows you how to use the package manager to install the Xdebug client and configure the current project to use it. He shows how to set up breakpoints and view the stack/watch data when the point is hit.

0 comments voice your opinion now!
debug xdebug sublimetext remote tutorial package client

Link: http://www.sitepoint.com/debugging-xdebug-sublime-text-3/

Lorna Mitchell:
Twitter Search API Using PHP and Guzzle
July 11, 2013 @ 12:49:45

Lorna Mitchell has a new post to her site today showing how she connected to Twitter with Guzzle, the popular PHP-based HTTP client (also used in the Amazon Web Services PHP client).

In case you missed it, Twitter updated their APIs recently, so that you have to authenticate to use even their search APIs to return publicly-available results. This is an increasing trend for API providers, to provide either very limited or nonexistent access for unauthenticated users, I think so they can rate limit consumers that swamp them. To cut a long story short, that meant I needed to update my dashboards that keep an eye on twitter searches to do more than just call file_get_contents in the general direction of the right URL.

She walks you through the creation of the client complete with the OAuth plugin (included with Guzzle) to make an OAuth request to api.twitter.com. With the client created, she shows a simple search call to the "tweets" endpoint.

0 comments voice your opinion now!
twitter search guzzle tutorial http client oauth api

Link: http://www.lornajane.net/posts/2013/twitter-search-api-using-php-and-guzzle

NetTuts.com:
From Procedural to Object Oriented PHP
June 24, 2013 @ 12:17:36

In this new tutorial from NetTuts.com, they want to help you make the move from procedural PHP to the world of Object-Oriented PHP. They opt for the mini-project approach and show you how to make a simple Google API client.

This tutorial was inspired by a speech given by Robert C. Martin that I watched a year or so ago. The main subject of his talk is about the possibility of picking The Last Programming Language. He addresses topics such as why should such a language exist? And what it should look like? However, if you read between the lines, there was another interesting idea that caught my attention: the limitations that each programming paradigm imposes upon on us programmers. So before we get into how we could go about converting a procedural based PHP app into an object oriented one, I want to cover a little bit of theory beforehand.

They start their example with a procedural approach, showing how to make the client and make a request for calendar information. They then work through the refactoring of the example, breaking it up into logical chunks (objects) and separating out some of the logic (like view versus logic). They talk about everything from basic OOP terms out to more complex ideas like SOLID.

0 comments voice your opinion now!
procedural objectoriented oop programming tutorial introduction google api client

Link: http://net.tutsplus.com/tutorials/php/from-procedural-to-object-oriented-php

Aleksey Korzun:
Benchmarking Memcached and Redis Clients
June 19, 2013 @ 11:06:31

Aleksey Korzun has posted some of the results from benchmarking he performed on various Memcached and Redis clients through PHP. His tests focused on multiple PHP client libraries, both user-land and extension based.

As some of you may know, I'm crazy about speed. So when I saw that people were happily using Predis as their choice of PHP client for Redis, I was a bit confused. Why use a client written in PHP for something that should be 'fast' like Redis? That kind of defeats the purpose - unless you don't really care about response times and scalability. [...] The performance difference piqued my interest. I wanted to find out just how much performance users are sacrificing by choosing one implementation over another.

He ran his tests on VirtualBox VM instances with the same specs and the same version of PHP installed. He tested various versions of the Memcached client, Redis client, Predis and the IgBinary extension. His results (Google spreadsheet) show the requests processed using each method based on this benchmarking script.You can visit the post to see the graphs of the results too.

0 comments voice your opinion now!
benchmark memcached redis client graph results

Link: http://alekseykorzun.com/post/53283070010/benchmarking-memcached-and-redis-clients

Gonzalo Ayuso:
Enqueue Symfony's process components with PHP and ZeroMQ
April 09, 2013 @ 11:11:59

Gonzalo Ayuso has a new post today showing how he set up queuing with ZeroMQ and Symfony components and React.

Today I'd like to play with ZeroMQ. ZeroMQ is a great tool to work with sockets. I will show you the problem that I want to solve: One web application needs to execute background processes but I need to execute those processes in order. Two users cannot execute one process at the same time. OK, if we face to this problem we can use Gearman. I've written various posts about Gearman (here and here for example). But today I want to play with ZeroMQ.

He uses React and some ZeroMQ bindings and Symfony's Process component to make a simple client and server for working with the queue and processes. A screencast is included in the post showing them making the connection and adding the new process. The full code can be found on github (or installable via Composer)

0 comments voice your opinion now!
zeromq symfony component process react server client tutorial

Link: http://gonzalo123.com/2013/04/08/building-a-zeromq-enqueue-with-php

Amazon Web Services Blog:
Version 2 of the AWS SDK for PHP (now with Guzzle)
November 15, 2012 @ 14:57:49

The Amazon Web Services group has recently released an updated version of their SDK for PHP and at it's heart is the open source project Guzzle (a HTTP client framework).

The new SDK is built on top of the Guzzle HTTP client framework, which provides increased performance and enables event-driven customization. Each AWS service client extends the Guzzle client and describes operations on the service using a service description file. The SDK now manages persistent connections for both serial and parallel requests. It detects transient network failures, with automatic retries using truncated exponential backoff. Support for event hooks (via the Symfony2 EventDispatcher) allows you to implement custom, event-driven behavior.

In the AWS post about the update, they give you a few code snippets showing this updated version in use. This completely reworked version of the SDK is not compatible with the previous version, so you'll need to consult their migration guide to bring things up to date.

0 comments voice your opinion now!
aws amazon webservices guzzle opensource http client version release sdk



Community Events





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


introduction opinion voicesoftheelephpant tips symfony list package deployment bugfix community framework series laravel install library language podcast interview release api

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