hollisho/http-client is a Laravel package for http-client.
It currently has 0 GitHub stars and 148 downloads on Packagist (latest version v1.2.2).
Install it with composer require hollisho/http-client.
Discover more Laravel packages by hollisho
or browse all Laravel packages to compare alternatives.
Last updated
$ composer require hollisho/http-client
if (file_exists(dirname(__FILE__) . '/vendor/autoload.php')) {
require_once dirname(__FILE__) . '/vendor/autoload.php';
}
// 注册 Doctrine 注解,为 PHP 8.0 做特殊处理
if (PHP_VERSION_ID >= 80000) {
// PHP 8.0+ 需要明确注册注解命名空间
if (class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
// 注册类加载器
AnnotationRegistry::registerLoader('class_exists');
// 显式注册 hollisho 的注解命名空间
if (method_exists(AnnotationRegistry::class, 'registerAutoloadNamespace')) {
AnnotationRegistry::registerAutoloadNamespace(
'hollisho\httpclient\Annotations',
dirname(__FILE__) . '/vendor/hollisho/http-client/src/Annotations'
);
}
}
} else {
// PHP 7.x
if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
AnnotationRegistry::registerLoader('class_exists');
}
}
$ ./vendor/phpunit/phpunit/phpunit --configuration phpunit.xml
$ ./vendor/phpunit/phpunit/phpunit --configuration phpunit.xml --test-suffix RequestTest.php
$ ./vendor/phpunit/phpunit/phpunit --configuration phpunit.xml --filter RequestTest
$ ./vendor/phpunit/phpunit/phpunit --configuration phpunit.xml --filter RequestTest::test
$httpClient = new BaseClient('https://www.1024plus.com');
$httpClient->pushMiddleware(new AuthRequest());
$httpClient->httpPost('/category/springboot/');
/**
* @author Hollis
* Interface UserService
*
* @BaseUrl(host="https://www.1024plus.com/")
*
* @package hollisho\httpclientTests\Service
*/
interface UserService
{
/**
* @Headers(headers={
* @AuthBasic(username="override", password="override"),
* @CustomHeader(name="x-override", body="test")
* })
*
* @Action(
* method=@Get,
* endpoint=@Endpoint(uri="/api/entry/{id}")
* )
*/
public function getUser($id);
/**
* @Action(
* method=@Post,
* endpoint=@Endpoint(uri="/resource"),
* body=@Body(json=true, name="body")
* )
*/
public function createUser($body);
}
// 生成 FeignClient 实例
$client = FeignClientFactory::create(UserService::class);
echo $client->getUser(1);