Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cosminseceleanu/restclientbundle
Symfony Rest Client Bundle
https://github.com/cosminseceleanu/restclientbundle
annotations guzzlehttp httpclient php restclient symfony
Last synced: about 1 month ago
JSON representation
Symfony Rest Client Bundle
- Host: GitHub
- URL: https://github.com/cosminseceleanu/restclientbundle
- Owner: cosminseceleanu
- License: mit
- Created: 2017-03-12T16:14:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-03-18T19:46:13.000Z (over 7 years ago)
- Last Synced: 2024-10-13T07:05:53.172Z (about 1 month ago)
- Topics: annotations, guzzlehttp, httpclient, php, restclient, symfony
- Language: PHP
- Homepage:
- Size: 35.2 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RestClientBundle
Symfony **Rest Client Bundle** using [GuzzleHttp](http://docs.guzzlephp.org/en/latest/index.html) and [Ocramius/ProxyManager](http://ocramius.github.io/ProxyManager/)
Installation
============To install CosRestClientBundle with Composer execute the following command:
$ composer require "cos/rest-client-bundle": "dev-master"
Now, Composer will automatically download all required files, and install them
for you. All that is left to do is to update your ``AppKernel.php`` file, and
register the new bundle:get('cos_rest_client.proxy_factory');
$proxy = $proxyFactory->create(Posts::class);Call proxy methods defined in interface
-----get(1); //request for client base uri + /posts/1
$proxy->getWithQuery(1)->getBody()->getContents(); //request for /posts?userId=1
$data = ['foo' => 'bar']
$proxy->form($data) //post request where $data is sent as application/x-www-form-urlencoded
$proxy->json($data) // send data as jsonResponse
-----
Every method call from a proxy return a [Psr\Http\Message\ResponseInterface](http://docs.guzzlephp.org/en/latest/quickstart.html#using-responses)Full example
--------
https://github.com/cosminseceleanu/RestClientBundleSampleEvents
=======**RequestEvent**: dispatched before a request is executed
**ResponseEvent**: dispatched when response is received