Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Retrofit-php 是一个 HTTP client 库,参考了 square/retrofit 的 API ,并使用 php 实现。

Notifications You must be signed in to change notification settings

mx1700/retrofit-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

21 Commits

Repository files navigation

Retrofit-php

Retrofit-php 是一个 HTTP client 库,参考了 square/retrofit 的 API ,并使用 php 实现。

概述

可以使用简单的接口来定义一个 HTTP client

interface GithubService
{
 /**
 * @Get("/users/{name}")
 */
 function getUser($name);
}

API的配置信息是通过 注解 来定义的(如上的 Get 注解),然后通过 ServiceFactory 类自动生成接口的实现

$factory = new ServiceFactory([ 'baseUrl' => 'https://api.github.com' ]);
$service = $factory->create(GithubService::class);

使用生成的 service 对象就可以调用 HTTP api 并返回结果

$user = $service->getUser('mx1700');

License

About

Retrofit-php 是一个 HTTP client 库,参考了 square/retrofit 的 API ,并使用 php 实现。

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /