Search code examples
restsymfonyrequestput

Sending REST Requests with Symfony2


Is there any bundle that can send REST requests to external web pages? I need PUT and DELETE as well as PATCH (http method).


Solution

  • You are looking for this bundle: https://github.com/CircleOfNice/CiRestClientBundle

    $restClient = $this->container->get('ci.restclient');
    
    $restClient->get('http://www.someUrl.com');
    $restClient->post('http://www.someUrl.com', 'somePayload');
    $restClient->put('http://www.someUrl.com', 'somePayload');
    $restClient->delete('http://www.someUrl.com');
    $restClient->patch('http://www.someUrl.com', 'somePayload');
    
    $restClient->head('http://www.someUrl.com');
    $restClient->options('http://www.someUrl.com', 'somePayload');
    $restClient->trace('http://www.someUrl.com');
    $restClient->connect('http://www.someUrl.com');