sdaoudi/sf-forward

SF Forward Requests

Installs: 31

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

v1.4 2019-04-07 16:02 UTC

This package is auto-updated.

Last update: 2024-05-09 12:33:49 UTC


README

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads

SfForwardBundle is a bundle that allows you to forward server-side HTTP requests using the Guzzle library.

INSTALLATION

To install this bundle, run the following command:

$ composer require sdaoudi/sf-forward

USAGE

Enable bundle:
SfForward\SfForwardBundle::class => ['all' => true],
Add the SfForward route to your routing.yml file:
sf_forward:
    resource: '@SfForwardBundle/Controller/SfForwardController.php'
    type: annotation
Guzzle configuration:

For the Guzzle configuration, see the 8p/EightPointsGuzzleBundle project documentation:

# EightPoints GuzzleBundle
# A full list of configuration options can be found here:
# https://github.com/8p/EightPointsGuzzleBundle/blob/master/src/Resources/doc/configuration-reference.md
eight_points_guzzle:
    clients:
        my_client:
            # Write here the host where to do requests
            base_url: "http://localhost:8000"

            # Request options: http://docs.guzzlephp.org/en/stable/request-options.html
            options:
                # timeout in seconds
                timeout: 30

                # set to false to disable throwing exceptions on an HTTP protocol errors (4xx and 5xx responses)
                http_errors: true

                # each key is the name of a header, and each value is a string or array of strings representing the
                # header field values.
                headers:
                    User-Agent: "EightPointsGuzzleBundle/v7"
Examples:
http://symfony.local//sfForwardFront/service=MyClient&routeId=_my_route_example_2174?key=value
  • service: is the key of the client configured with Guzzle.
  • routeId: is the target route, just replace the slashes (/) by underscores (_).

In order to respect Symfony naming conventions, the service passed in parameter would be transformed into Snake Case.