sdaoudi / sf-forward
SF Forward Requests
Installs: 32
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^5.6 || ^7.0
- eightpoints/guzzle-bundle: ~6.0 || ~7.0
- nayjest/str-case-converter: ^1.0
- symfony/filesystem: ^2.8 || ^3.4 || ^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- phpunit/phpunit: ^5.7 || ^6.5
- symfony/phpunit-bridge: ^2.8 || ^3.4 || ^4.0
README
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.