Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
86 lines (65 sloc) 3.16 KB

Introduction

GuzzleBundle is a Symfony2 bundle for integrating the Guzzle PHP library in your project.

It’s not quite finished.

Installation

  1. Install Guzzle and GuzzleBundle as a Git submodule:

    $ git submodule add git://github.com/guzzle/guzzle.git vendor/guzzle/guzzle $ git submodule add git://github.com/guzzle/GuzzleBundle vendor/bundles/Guzzle/GuzzleBundle

    Or configure your deps to include the bundle:

     [Guzzle]
         git=git://github.com/guzzle/guzzle.git
         target=guzzle/guzzle
    
     [GuzzleBundle]
         git=git://github.com/guzzle/GuzzleBundle.git
         target=bundles/Guzzle/GuzzleBundle
    
  2. Add the Guzzle and GuzzleBundle namespace to your autoloader:

     // app/autoload.php
     $loader->registerNamespaces(array(
           'Guzzle\\GuzzleBundle' => __DIR__.'/../vendor/bundles',
           'Guzzle'               => __DIR__.'/../vendor/guzzle/guzzle/src',
           // your other namespaces
     ));
    
  3. Add this bundle to your application's kernel:

     // app/AppKernel.php
     public function registerBundles()
     {
         // ...
         new Guzzle\GuzzleBundle\GuzzleGuzzleBundle(),
         // ...
     }
    
  4. Configure the service_builder service, and ensure that the framework is using the filesystem for session storage:

     # app/config/config.yml
     guzzle_guzzle:
         service_builder: ~
    
  5. And add a Guzzle clients configuration file. See the Guzzle documentation.

    // app/config/guzzleclients.xml

Usage

In any of your app controller, use the service builder to instantiate a client:

    $serviceBuilder = $this->get('guzzle.service_builder');
    $client = $serviceBuilder->get('unfuddle');