PHP code example of gehrisandro / laravel-http-psr18
1. Go to this page and download the library: Download gehrisandro/laravel-http-psr18 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gehrisandro / laravel-http-psr18 example snippets
use HttpPsr18\HttpPsr18;
$client = HttpPsr18::make();
// example usage with OpenAI for Laravel (https://github.com/openai-php/laravel)
$openAI = \OpenAI::factory()
->withApiKey('*******')
->withHttpClient($client)
->make();
$response = $openAI->chat()->create([/* ... */]);
use HttpPsr18\HttpPsr18;
use Illuminate\Support\Facades\Http;
$client = HttpPsr18::make(Http::timeout(300));
use GuzzleHttp\Psr7\Request;
use HttpPsr18\HttpPsr18;
use Illuminate\Support\Facades\Http;
Http::fake([
'*' => Http::response('Hello World'),
]);
$client = HttpPsr18::make();
$response = $client->sendRequest(new Request('GET', 'https://example.com'));
$response->getBody()->getContents(); // Hello World
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.