laravel guzzle get 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: laravel 6 make http request

$client = new GuzzleHttp\Client();
$res = $client->get('https://api.github.com/user', ['auth' =>  ['user', 'pass']]);
echo $res->getStatusCode(); // 200
echo $res->getBody(); // { "type": "User", ....

Example 3: laravel http client

composer require guzzlehttp/guzzle

Example 4: laravel http client

use Illuminate\Support\Facades\Http;

$response = Http::get('http://test.com');

Example 5: pass guzzle client data to view laravel

$html = \View::make('view', ['some' => 'data'])->render();

Example 6: pass guzzle client data to view laravel

@foreach($clients as $value)
    <tr>
      <td>{{$value["name"]}}</td>
      <td>{{$value["email"]}}</td>
      <td>{{$value["number"]}}</td>
    </tr>
@endforeach