molchanoviv / retrofit-php
是 tebru/retrofit-php 的分支
v2.8.3
2016-09-12 14:47 UTC
Requires
- php: >= 5.4
- guzzlehttp/psr7: ^1.0
- jms/serializer: ^1.0
- phpoption/phpoption: ^1.1
- psr/log: ^1.0
- symfony/console: ^2.3|^3.0
- symfony/event-dispatcher: ^2.3|^3.0
- tebru/assert: 0.2
- tebru/retrofit-http-clients: v0.6.6
Requires (Dev)
- behat/behat: ^3.1
- guzzlehttp/guzzle: ^5.3|^6.0
- incenteev/composer-parameter-handler: ~2.0
- mockery/mockery: ^0.9.4
- monolog/monolog: ^1.18
- phpunit/phpunit: >= 4, < 6
- sensio/distribution-bundle: ^5.0
- sensio/framework-extra-bundle: ^3.0.2
- symfony/symfony: ^3.0
- tebru/dynamo: 0.3.1
Suggests
- guzzlehttp/guzzle: Required to make requests
- dev-master
- v2.8.3
- v2.8.2
- v2.8.1
- v2.8.0
- v2.8.0-rc4
- v2.8.0-rc3
- v2.8.0-rc2
- v2.8.0-rc1
- v2.7.0
- v2.6.1
- v2.6.0
- v2.5.5
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- v0.3.5
- v0.3.4
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.1
- v0.2.0
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-lambda_handlers
- dev-param_transformers
- dev-develop
This package is not auto-updated.
Last update: 2024-09-14 19:42:14 UTC
README
这个库旨在简化REST客户端的创建。它明显借鉴了 square/retrofit 并用PHP实现。
概述
Retrofit 允许您使用简单的接口定义您的REST API。
<?php use Tebru\Retrofit\Annotation as Rest; interface GitHubService { /** * @Rest\GET("/users/{user}/list") * @Rest\Returns("ArrayCollection<ListRepo>") */ public function listRepos($user); }
使用注解来配置端点。然后,RestAdapter
类生成服务接口的有效实现。
<?php use Tebru\Retrofit\Adapter\RestAdapter; $restAdapter = RestAdapter::builder() ->setBaseUrl('https://api.github.com') ->build(); $gitHubService = $restAdapter->create(GitHubService::class);
我们新创建的服务能够向 /users/$user/list 发送GET请求,以返回一个包含 ListRepo 对象的 ArrayCollection。
$repos = $gitHubService->listRepos('octocat');
使用示例参考自 Square 的文档
安装与使用
composer require tebru/retrofit-php
请确保您还安装了一个HTTP客户端。目前,只有 guzzle 是支持的选择
composer require guzzlehttp/guzzle
文档
许可证
本项目采用 MIT 许可证。有关更多信息,请参阅 LICENSE
文件。