2017 © Pedro PelĂĄez
 

library guztav

A small RESTful API client around PHP Guzzle

image

joseluisq/guztav

A small RESTful API client around PHP Guzzle

  • Tuesday, May 2, 2017
  • by joseluisq
  • Repository
  • 1 Watchers
  • 1 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Guztav

A small RESTful API client around PHP Guzzle., (*1)

Build Status Latest Stable Version Latest Unstable Version Total Downloads License, (*2)

Features

  • It's only a wrapper around Guzzle. It means that you can use the same API like: Client, Request and Response objects.
  • Some helper functions for more friendly Response data handling like : $response->toArray(), $response->toString(), etc.
  • You can define your BASE_URI and ACCESS_TOKEN settings via .env file. For example using Dotenv package (optional).

Install

composer require joseluisq/guztav

Usage

Settings via .env file

# Define your API settings
GUZTAV_BASE_URI='http://localhost:8001/api/v1/'
GUZTAV_ACCESS_TOKEN='eyJ0eXBiOiJKV1QiLCN0bx.....'
  • GUZTAV_BASE_URI : The same Guzzle base_uri param for Client settings.
  • GUZTAV_ACCESS_TOKEN : It will be to added to the current header like Authorization: Bearer ... (optional)

Settings via constructor

You can also pass the same Guzzle options for Client object., (*3)

<?php

use Guztav\Client;

// Setting the client
$client = new \Guztav\Client([
    // Define these params if you don't use some .env file
    'base_uri' => 'http://localhost:8001/api/v1/',
    'access_token' => 'eyJ0eXBiOiJKV1QiLCN0bx.....', // Optional

    // More options...
    'headers' => ['Accept' => 'application/json'],
    'timeout'  => 2.0,
    ...
]);

Making a request

<?php

use Guztav\Client;

$client = new \Guztav\Client();

// My GET request
$response = $client->get('client/1', [
    'query' => ['a' => 1, 'b' => 2]
]);
$string = $response->toString();


// My JSON POST request
$params = [
    'name' => 'Octocat',
    'email' => 'octo.cat@github.com',
];
$array = $client->post('client', [
    'json' => $params
])->toArray();

Note: By now, Guztav supports application/json response data only., (*4)

License

MIT license, (*5)

© 2017 José Luis Quintana, (*6)

The Versions

02/05 2017

dev-master

9999999-dev http://guzzlephp.org/

A small RESTful API client around PHP Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

curl json rest http client web service http client

02/05 2017

1.0.2

1.0.2.0 http://guzzlephp.org/

A small RESTful API client around PHP Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

curl json rest http client web service http client

13/04 2017

1.0.1

1.0.1.0 http://guzzlephp.org/

A small RESTful API client around PHP Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

curl json rest http client web service http client

04/04 2017

1.0.0

1.0.0.0 http://guzzlephp.org/

A small RESTful API client around PHP Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

curl json rest http client web service http client

03/04 2017

1.0.0-beta.1

1.0.0.0-beta1 http://guzzlephp.org/

A small RESTful API client around PHP Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

curl json rest http client web service http client