ddeboer/guzzle-bundle

此包已废弃,不再维护。未建议替代包。

此Bundle为guzzle HTTP客户端提供与Symfony2的集成,以便访问RESTful API。

安装次数: 4,025

依赖者: 1

建议者: 0

安全: 0

星标: 64

关注者: 10

分支: 29

开放问题: 10

类型:symfony-bundle

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

This package is not auto-updated.

Last update: 2022-02-01 12:20:58 UTC


README

DdeboerGuzzleBundle是一个用于在项目中集成Guzzle PHP库的Symfony2 Bundle。

安装

安装是一个快速(我保证!)的4步骤过程

  1. 下载DdeboerGuzzleBundle
  2. 配置自动加载器
  3. 启用Bundle
  4. 配置DdeboerGuzzleBundle

第1步:下载DdeboerGuzzleBundle

最终,GuzzleBundle文件应该下载到vendor/bundles/Ddeboer/GuzzleBundle目录。

这可以通过几种方式完成,具体取决于您的偏好。第一种方法是标准的Symfony2方法。

使用供应商脚本

在您的deps文件中添加以下行

[guzzle]
    git=git://github.com/guzzle/guzzle.git
    target=guzzle

[DdeboerGuzzleBundle]
    git=git://github.com/ddeboer/GuzzleBundle.git
    target=bundles/Ddeboer/GuzzleBundle

现在,运行供应商脚本来下载此包

$ php bin/vendors install

使用子模块

如果您更愿意使用git子模块,请运行以下命令

$ git submodule add git://github.com/guzzle/guzzle.git vendor/guzzle
$ git submodule add git://github.com/ddeboer/GuzzleBundle vendor/bundles/Ddeboer/GuzzleBundle
$ git submodule update --init

第2步:配置自动加载器

GuzzleDdeboer命名空间添加到您的自动加载器中

<?php
// app/autoload.php
$loader->registerNamespaces(array(
    // ...
    'Guzzle'           => __DIR__.'/../vendor/guzzle/src',
    'Ddeboer'          => __DIR__.'/../vendor/bundles',
));

第3步:启用Bundle

最后,在内核中启用该Bundle

<?php
// app/AppKernel.php

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

第4步:配置DdeboerGuzzleBundle

# app/config/config.yml
ddeboer_guzzle: 
    service_builder:
        configuration_file: "%kernel.root_dir%/config/webservices.xml"

并添加一个Guzzle服务配置文件。请参阅Guzzle文档

<!-- app/config/webservices.xml -->
<?xml version="1.0" ?>
<guzzle>
    <clients>
        <!-- Abstract service to store AWS account credentials -->
        <client name="abstract.aws">
            <param name="access_key" value="12345" />
            <param name="secret_key" value="abcd" />
        </client>
        <!-- Amazon S3 client that extends the abstract client -->
        <client name="s3" class="Guzzle.Aws.S3.S3Client" extends="abstract.aws">
            <param name="devpay_product_token" value="XYZ" />
            <param name="devpay_user_token" value="123" />
        </client>
        <client name="simple_db" class="Guzzle.Aws.SimpleDb.SimpleDbClient" extends="abstract.aws" />
        <client name="sqs" class="Guzzle.Aws.Sqs.SqsClient" extends="abstract.aws" />
        <!-- Unfuddle client -->
        <client name="unfuddle" class="Guzzle.Unfuddle.UnfuddleClient">
            <param name="username" value="test-user" />
            <param name="password" value="my-password" />
            <param name="subdomain" value="my-subdomain" />
        </client>
    </clients>
</guzzle>

许可证

此包受MIT许可证的约束。请参阅包中的完整许可证。

Resources/meta/LICENSE