2017 © Pedro Peláez
 

project rest-client

Simple PHP REST client

image

chriha/rest-client

Simple PHP REST client

  • Monday, March 6, 2017
  • by chriha
  • Repository
  • 2 Watchers
  • 1 Stars
  • 218 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 17 Versions
  • 3 % Grown

The README.md

rest-client

Build Status, (*1)

A simple REST client with PHPs cURL., (*2)

Install

composer require chriha/rest-client

Usage

Define your options, (*3)

$options = [
    'url' => 'http://api.localhost/v1',
];

See \Chriha\Clients\Rest::getDefaultOptions() for all default options., (*4)

GET

$rest = new \Chriha\Clients\Rest( $options );
$rest->get( '/posts' );

POST

$post = [
    "title" => "lorem",
    "body"  => "lorem ipsum dolor set"
];

$rest = new \Chriha\Clients\Rest( $options );
$rest->post( '/posts', $post );

PUT / PATCH

$post = [
    "title" => "lorem"
];

$rest = new \Chriha\Clients\Rest( $options );
$rest->put( '/posts/1', $post );
$rest->patch( '/posts/1', $post );

DELETE

$rest = new \Chriha\Clients\Rest( $options );
$rest->delete( '/posts/1' );

Options

Allow self signed certificates

Recommended only in dev environment, so default is false, (*5)

$options = [
    'allow_self_signed' => true,
];

Set additional cURL options

$options = [
    'curl_options' => [...],
];

OAuth 1.0 authentication

$options = [
    'authentication' => 'oauth1',
    'token'          => 'YOUR_API_TOKEN',
    'secret'         => 'YOUR_API_SECRET',
];

Using the CLI rest client

Make an alias like alias rest='vendors/bin/rest' for simpler usage of the client inside the project., (*6)

With the following command you can do a request via the rest client., (*7)

$ ./rest GET http://api.localhost.io/v1/posts "parameters=specified&as=simple&query=string" "Content-Type:application/json;Accept-Charset: utf-8"

If you want to use token and secret for your authentication, you can place them as JSON in the .rest file of your project root:, (*8)

{
    "token": "YOUR_API_TOKEN",
    "secret": "YOUR_API_SECRET"
}

The output of the rest client will be shown as the following:, (*9)

Request took 23.45ms
Response Code: 200
Response Body:
{
    "meta": "info",
    "data": [
        {
            "title": "lorem"
        }
    ]
}

The Versions

06/03 2017

dev-master

9999999-dev

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

06/03 2017

0.6.4

0.6.4.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

06/03 2017

dev-develop

dev-develop

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

16/09 2016

0.6.3

0.6.3.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

16/09 2016

0.6.2

0.6.2.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

14/07 2016

0.6.1

0.6.1.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

12/07 2016

0.6.0

0.6.0.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

06/07 2016

0.5.0

0.5.0.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

05/07 2016

0.4.3

0.4.3.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

28/06 2016

0.4.2

0.4.2.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

28/06 2016

0.4.1

0.4.1.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

28/06 2016

0.4.0

0.4.0.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

 

The Development Requires

rest client

19/06 2016

0.3.0

0.3.0.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

  • php >=5.5.0
  • ext-curl *

 

The Development Requires

rest client

18/05 2016

0.2.2

0.2.2.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

  • php >=5.5.0
  • ext-curl *

 

The Development Requires

rest client

13/05 2016

0.2.1

0.2.1.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

  • php >=5.5.0
  • ext-curl *

 

The Development Requires

rest client

11/05 2016

0.2.0

0.2.0.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

  • php >=5.5.0
  • ext-curl *

 

The Development Requires

rest client

07/05 2016

0.1.0

0.1.0.0

Simple PHP REST client

  Sources   Download

MIT

The Requires

  • php >=5.5.0
  • ext-curl *

 

The Development Requires

rest client