How I managed to make work Guzzle REST client library under Symfony 2.0.x as a bundle [Snipet]

Warning This is not a cut and paste solution. But some notes I want to share on how I did and what I’d like to cover and remember when I will continue working with that aspect on my current projects.

The problem i had was mostly that i had to see where to mix-and-match things between this wonderful library and Symfony2. I discovered after searching here that it’s not that complicated, you just need to get through the learning curve of reading the code AND the documentation.

I am posting here the hilight of what I have been struggling with and will re-read soon about how to use it and implement in into Symfony2.

Things I wished I understood faster

  • How to inject the configuration from symfony without hardcoding paths in my Managers/Controllers
  • Why do the XML configuration file has nodes like <client> in the main project file, but it’s not what triggers the Command. Answer: Use ServiceDescription::factory($xmlFileFullPath) from the Client class. Yes, it has <client> nodes… NO, they are not the same as in the client definition file xml (guzzleclients.xml).
  • How to extend a DynamicCommand from the ServiceDescription

The Gist

Improvement paths

Actually, now that I went through all this, A simple yaml annotation with a simple service definition with @MyBlogBundle/Resources/config/serviceDescription.clientName.xml could had done the job.