PHP code example of webman-tech / laravel-http-client

1. Go to this page and download the library: Download webman-tech/laravel-http-client 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/ */

    

webman-tech / laravel-http-client example snippets


return [
    // 其他配置省略
    'macros' => [
        'httpbin' => function() {
            return Http::baseUrl('https://httpbin.org')
                ->asJson();
        }
    ],
];

$response = \WebmanTech\LaravelHttpClient\Facades\Http::httpbin()->get('get', ['abc' => 'xyz']);



namespace support\facade;

use Illuminate\Http\Client\PendingRequest;

/**
 * @method static PendingRequest httpbin()
 */
class Http extends \WebmanTech\LaravelHttpClient\Facades\Http
{
    public static function getAllMacros(): array
    {
        return [
            'httpbin' => function() {
                return Http::baseUrl('https://httpbin.org')
                    ->asJson();
            }
        ];
    }
}

$response = \support\facade\Http::httpbin()->get('get', ['abc' => 'xyz']);