encore-labs/guzzle-bundle-header-forward-plugin

一个Guzzle插件,允许您自动将当前请求的头部信息转发到Guzzle请求中。已分支以支持Symfony 4

v3.0.1 2020-03-24 09:07 UTC

This package is not auto-updated.

Last update: 2024-09-18 08:08:46 UTC


README

# Guzzle Bundle Header Forwarding Plugin

此插件提供了一种将当前Symfony请求的头部信息转发到cURL的方法。

要求

安装

使用 composer

composer.json
{
    "require": {
        "encore-labs/guzzle-bundle-header-forward-plugin": "^1.0"
    }
}
命令行
$ composer require encore-labs/guzzle-bundle-header-forward-plugin

使用方法

启用插件

# app/AppKernel.php

new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle([
    new EncoreLabs\Bundle\GuzzleBundleHeaderForwardPlugin\GuzzleBundleHeaderForwardPlugin(),
])

基本配置

# app/config/config.yml

eight_points_guzzle:
    clients:
        api_payment:
            base_url: "http://api.domain.tld"

            # define headers, options

            # plugin settings
            plugin:
                header_forward:
                    enabled: true
                    headers:
                        - 'Accept-Language'