laravel http client transform code example

Example 1: use guzzle http client laravel

public function putGuzzleRequest()

{

    $client = new \GuzzleHttp\Client();

    $url = "http://myexample.com/api/posts/1";

    $myBody['name'] = "Demo";

    $request = $client->put($url,  ['body'=>$myBody]);

    $response = $request->send();



    dd($response);

}

Example 2: ensure a header is included with request laravel

// Returns header value with default as fallback
$request->header('someHeader', 'defaultValue');

// Returns boolean
$request->headers->has('someHeader');