mi-la01 / kt_guzzle-silex
该包的最新版本(1.0.1)没有提供许可证信息。
Guzzle3 silex 提供商(kt)
1.0.1
2015-07-07 18:52 UTC
Requires
- php: >=5.3.2
- guzzle/guzzle: >=2.0.0
This package is not auto-updated.
Last update: 2024-09-18 09:22:20 UTC
README
GuzzleServiceProvider 通过 Michael Dowling 的 Guzzle 框架提供 Guzzle ServiceBuilder 和默认客户端对象。Guzzle 是一个 PHP HTTP 客户端和用于构建 RESTful 网络服务客户端的框架。
您需要安装 Guzzle 的一个副本才能使用此服务提供商。安装 Guzzle。
参数
- guzzle.services: (可选)数组|string|SimpleXMLElement 描述您的网络服务客户端的数据。您可以通过文件路径 (.js|.json|.php)、数据数组或包含配置数据的 SimpleXMLElement 实例来传递。有关更多信息,请参阅 Guzzle 文档。
- guzzle.base_url: (可选)默认网络服务客户端的基本 URL。如果省略,实际调用必须使用绝对 URL。
- guzzle.plugins: (可选)要注册到客户端的 Guzzle 插件数组。
服务
- guzzle: 实例化的 Guzzle ServiceBuilder。
- guzzle.client: 使用基本 URL 的默认 Guzzle 网络服务客户端。
注册
require __DIR__ . '/../silex.phar';
require __DIR__ . '/../vendor/Guzzle/GuzzleServiceProvider.php';
use Silex\Application;
use Guzzle\GuzzleServiceProvider;
$app = new Application();
$app->register(new GuzzleServiceProvider(), array(
'guzzle.services' => '/path/to/services.json',
));
示例用法
使用实例化的 ServiceBuilder
// Get a command "foo" from "my_client"
$result = $app['guzzle']['my_client']->getCommand('foo');
$result = $foo->execute();
使用 Guzzle 客户端
$response = $app['guzzle.client']->head('http://www.guzzlephp.org')->send();
更多信息
有关 Guzzle ServiceBuilder 的更多信息,请参阅 http://docs.guzzlephp.org/en/latest/webservice-client/using-the-service-builder.html