snorlax - легковесный REST клиент на php
Пример использования
[
'method' => 'GET',
'path' => '/',
],
'get' => [
'method' => 'GET',
'path' => '/{0}.json',
],
'create' => [
'method' => 'POST',
'path' => '/',
],
];
}
}
$client = new RestClient([
'resources' => [
'pokemons' => PokemonResource::class,
],
]);
// GET http://localhost/api/pokemons?sort=id:asc
$response = $client->pokemons->all([
'query' => [
'sort' => 'id:asc',
],
]);
// GET http://localhost/api/pokemons/143.json?fields=id,name
$response = $client->pokemons->get(143, [
'query' => [
'fields' => 'id,name',
],
]);
// POST http://localhost/api/pokemons
$response = $client->pokemons->create([
'body' => [
'name' => 'Bulbasaur',
],
]);
https://github.com/ezdeliveryco/snorlax