php.blade.php 897 B

12345678910111213141516171819202122232425262728
  1. ```php
  2. $client = new \GuzzleHttp\Client();
  3. @if($hasRequestOptions)
  4. $response = $client->{{ strtolower($route['methods'][0]) }}(
  5. '{{ rtrim($baseUrl, '/') . '/' . ltrim($route['boundUri'], '/') }}',
  6. [
  7. @if(!empty($route['headers']))
  8. 'headers' => {!! \Mpociot\ApiDoc\Tools\Utils::printPhpValue($route['headers'], 4) !!},
  9. @endif
  10. @if(!empty($route['cleanQueryParameters']))
  11. 'query' => [
  12. @foreach($route['cleanQueryParameters'] as $parameter => $value)
  13. '{{$parameter}}' => '{{$value}}',
  14. @endforeach
  15. ],
  16. @endif
  17. @if(!empty($route['cleanBodyParameters']))
  18. 'json' => {!! \Mpociot\ApiDoc\Tools\Utils::printPhpValue($route['cleanBodyParameters'], 4) !!},
  19. @endif
  20. ]
  21. );
  22. @else
  23. $response = $client->{{ strtolower($route['methods'][0]) }}('{{ rtrim($baseUrl, '/') . '/' . ltrim($route['boundUri'], '/') }}');
  24. @endif
  25. $body = $response->getBody();
  26. print_r(json_decode((string) $body));
  27. ```