socloz / guzzle-bundle
此Bundle为guzzle HTTP客户端提供集成,以便使用Symfony2访问RESTful API
v1.0.0
2012-10-25 17:46 UTC
Requires
- php: >=5.3.2
- guzzle/guzzle: 2.8.*
- symfony/symfony: >=2.0,<2.2
This package is not auto-updated.
Last update: 2024-09-22 02:26:53 UTC
README
DdeboerGuzzleBundle是一个用于将Guzzle PHP库集成到您项目的Symfony2 Bundle。
安装
使用composer
-
在项目的
composer.json
文件中将socloz/guzzle-bundle
添加为依赖项{ "require": { "socloz/guzzle-bundle": "dev-socloz-master", } }
-
安装依赖项
php composer.phar update
启用Bundle
在kernel中启用Bundle
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Ddeboer\GuzzleBundle\DdeboerGuzzleBundle(), ); }
配置Bundle
添加自定义服务客户端
<?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;
}
}
并配置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
有关更多信息,请参阅Guzzle文档
许可证
此Bundle采用MIT许可证。在Bundle中查看完整的许可证。
Resources/meta/LICENSE