molchanoviv / retrofit-php
a fork of tebru/retrofit-php
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-11-09 20:33:46 UTC
README
This library aims to ease creation of REST clients. It is blatantly stolen from square/retrofit and implemented in PHP.
Overview
Retrofit allows you to define your REST API with a simple interface.
<?php use Tebru\Retrofit\Annotation as Rest; interface GitHubService { /** * @Rest\GET("/users/{user}/list") * @Rest\Returns("ArrayCollection<ListRepo>") */ public function listRepos($user); }
Annotations are used to configure the endpoint.
Then, the RestAdapter
class generates a working implementation of the
service interface.
<?php use Tebru\Retrofit\Adapter\RestAdapter; $restAdapter = RestAdapter::builder() ->setBaseUrl('https://api.github.com') ->build(); $gitHubService = $restAdapter->create(GitHubService::class);
Our newly created service is capable of making GET requests to /users/$user/list to return an ArrayCollection of ListRepo objects.
$repos = $gitHubService->listRepos('octocat');
Usage examples are referenced from Square's documentation
Installation & Usage
composer require tebru/retrofit-php
Please make sure you also install an http client. Currently guzzle is the only supported option
composer require guzzlehttp/guzzle
Documentation
License
This project is licensed under the MIT license. Please see the LICENSE
file
for more information.