socloz/guzzle-bundle

This Bundle provide integration for guzzle http client to access RESTful API's with Symfony2

Installs: 22 657

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 12

Forks: 29

Type:symfony-bundle

v1.0.0 2012-10-25 17:46 UTC

This package is not auto-updated.

Last update: 2024-04-21 00:33:00 UTC


README

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

Installation

Using composer :

  1. Add socloz/guzzle-bundle as a dependency in your project's composer.json file:

     {
         "require": {
             "socloz/guzzle-bundle": "dev-socloz-master",
         }
     }
    
  2. Install your dependencies:

     php composer.phar update
    

Enable the bundle

Enable the bundle in the kernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Ddeboer\GuzzleBundle\DdeboerGuzzleBundle(),
    );
}

Configure the bundle

Add a custom service client :

<?php

/*
 * Copyright CloseToMe 2011/2012
 */

namespace Acme\ExampleBundle\Webservice;

use Guzzle\Common\Collection;
use Guzzle\Service\Client;
use Guzzle\Service\Description\ServiceDescription;

class MyWebserviceClient extends Client
{

    public static function factory($config = array())
    {
        $client = new self($config['base_url'], $config);

        // Add custom setup code

        // Attach a service description to the client
        $description = ServiceDescription::factory($config);
        $client->setDescription($description);

        return $client;
    }
}

And configure the webservice :

# app/config/config.yml
ddeboer_guzzle:
  service_builder:
    configuration:
      Stats:
        class: "Acme\\ExampleBundle\\Webservice\\MyWebserviceClient"
        params:
          operations:
            OperationName:
              httpMethod: GET
              uri: /search
              parameters:
                query:
                  location: query
                  required: true
                  type: string
                sort:
                  location: query
                  type: string

See the Guzzle documentation for more information.

License

This bundle is under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE