2017 © Pedro Peláez
 

library php-rest-client

PHP REST Client

image

adam-innes/php-rest-client

PHP REST Client

  • Saturday, June 30, 2018
  • by _adam
  • Repository
  • 1 Watchers
  • 2 Stars
  • 156 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 5 % Grown

The README.md

PHP RESTful Client Library

Synopsis

This is an easy to use client for RESTful web services., (*1)

Setup

Installation with Composer.

Clone the repository., (*2)

$ git clone https://github.com/innesian/PhpRestClient.git

Install Composer in your project using cURL (command below) or download the composer.phar directly., (*3)

$ curl -sS http://getcomposer.org/installer | php

Let Composer install the project dependencies:, (*4)

$ php composer.phar install

Once installed, include the autoloader in your script., (*5)

<?php
include_once 'vendor/autoload.php'; // Path to autoload.php file.
$rest = new \PhpRestClient\PhpRestClient('http://base.url/to/api/');

(or) add PhpRestClient as a dependency to your REST project using Composer.

Create a composer.json file in your project and add adam-innes/php-rest-client as a required dependency., (*6)

{
    "require": {
        "adam-innes/php-rest-client": "1.0.*"
    }
}

Usage

Standard Requests

$rest = new \PhpRestClient\PhpRestClient('http://base.url/to/api');

/** Get Example **/
# Set custom headers.
$headers = array(
    'CURLOPT_VERBOSE' => true,
);
# The get function will take a query string or array of parameters.
$response = $rest->get('account/information', 'variable=1&variable=2', $headers);

/** Put Example **/
$params['variable_1'] = 'value_1';
$params['variable_2'] = 'value_2';
$response = $rest->put('user/information', $params);

/** Post Example **/
$params['variable_1'] = 'value_1';
$params['variable_2'] = 'value_2';
$response = $rest->post('user/information', $params);

/** Delete Example **/
$response = $rest->delete('delete/user/5');

Basic and Digest Authentication

The setAuthentication() function will set Basic or Digest authenication headers for the remainder of the session unless explicitly unset., (*7)

Authentication uses Basic by default. The unsetAuthentication() function will clear out the authentication headers., (*8)

$rest = new \PhpRestClient\PhpRestClient('http://base.url/to/api');
# Set Basic Authentication Headers.
$rest->setAuthentication('myUsername', 'myPassword', CURLAUTH_DIGEST);
$rest->get('account/information');
# Unset the Authentication headers.
$rest->unsetAuthentication();

The Versions

30/06 2018

dev-master

9999999-dev

PHP REST Client

  Sources   Download

The Requires

  • php >=5.4.0

 

by Adam Innes

30/06 2018

1.0.6

1.0.6.0

PHP REST Client

  Sources   Download

The Requires

  • php >=5.4.0

 

by Adam Innes

24/02 2016

1.0.5

1.0.5.0

PHP REST Client

  Sources   Download

The Requires

  • php >=5.4.0

 

by Adam Innes

15/02 2016

1.0.2

1.0.2.0

PHP REST Client

  Sources   Download

The Requires

  • php >=5.4.0

 

by Adam Innes

13/02 2016

1.0.1

1.0.1.0

PHP REST Client

  Sources   Download

The Requires

  • php >=5.4.0

 

by Adam Innes

11/02 2016

1.0

1.0.0.0

PHP REST Client

  Sources   Download

The Requires

  • php >=5.4.0