Setting up Symfony2 with Guzzle Part 1

So in working with my latest project I needed to make some REST calls through PHP.  After doing a bit of research I decided to use Guzzle  The reason why I decided to use Guzzle is that it’s simple, easily extensible, and has a testing framework.  So I’m going to make a few assumptions in this tutorial.  I’m assuming that you’ve already got Symfony2 up and running on your machine.  If not, go to and follow the Get Started link to get up and running.  So now without further ado!

  1. Navigate to your Symfony2 location and run this:
    git submodule add git:// vendor/guzzle
    git submodule add git:// vendor/bundles/Ddeboer/GuzzleBundle
  2. Now go to your Autoload.php (app/autoload.php) file and register namespaces.
    $loader->registerNamespaces(array(// ...
    'Guzzle' => __DIR__.'/../vendor/guzzle/src',
    'Ddeboer' => __DIR__.'/../vendor/bundles',
    // ...
  3. Add the GuzzleBundle to your application kernel. (app/AppKernel.php)
    public function registerBundles()
    // ...
    new Ddeboer\GuzzleBundle\DdeboerGuzzleBundle(),
    // ...
  4. The last step you need to do is set up your Guzzle service builder. (app/config/config.yml)

    configuration_file: "%kernel.root_dir%/config/webservices.xml"
    adapter: doctrine
    driver: apc
    I had some problems with the cache section so you can remove that if you run into any problems.

Now you’re all set up to start sending REST requests through Guzzle in your Symfony2 application.  Next blog post I’ll show you how to use Guzzle’s extensibility (that should definitely be a word) to turn your REST calls into an API that’s super easy to use.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s