2017 © Pedro Peláez
 

library php-restservice

Simple PHP Wrapper class for making REST API calls

image

abhilashpujari/php-restservice

Simple PHP Wrapper class for making REST API calls

  • Saturday, July 21, 2018
  • by abhilashpujari
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 10 % Grown

The README.md

PHP HTTP REST Client

CI build Lint Code Base, (*1)

Simple PHP Client library that makes it easy to make REST API calls. It uses Guzzle Client as a dependencies, (*2)

Installation

The recommended way to install this library is through Composer., (*3)

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version of this library:, (*4)

php composer.phar require abhilashpujari/php-restservice dev-master

After installing, you need to require Composer's autoloader:, (*5)

require 'vendor/autoload.php';

You can then later update this library using composer:, (*6)

bash php composer.phar update, (*7)

## Usage, (*8)

1 GET Request, (*9)

```php use RestService\RestService;, (*10)

$restService = new RestService(); $response = $restService ->setEndpoint('https://jsonplaceholder.typicode.com') ->get('/posts/1'); ```, (*11)

2 POST Request, (*12)

$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->post('/posts');

3 PUT Request, (*13)

$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->put('/posts/1',
         [
             'id' => 1,
             'text' => 'Test'
         ]
     );

4 PATCH Request, (*14)

$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->patch('/posts/1',
         [
             'id' => 1,
             'text' => 'Test'
         ]
     );

5 DELETE Request, (*15)

$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->delete('/posts/1');

6 A fire and forget request which is useful in scenario where we fire the request and aren't concerned of the response, it can be done by setting setIsFireAndForget(true), (*16)

$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->setIsFireAndForget(true)
     ->post('/posts');

7 Request with some custom headers, , it can be done by setting setRequestHeaders(headers array), (*17)

$restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->setRequestHeaders([
         'auth' => 'somevalue'
     ])
     ->post('/posts');

8 Request in which we need the response data which includes status code, headers, body etc, which can be done by setting request method 4th parameter to false, (*18)

$response = $restService
     ->setEndpoint('https://jsonplaceholder.typicode.com')
     ->get('/posts/1', [], [], false);

 var_dump($response->getHeaders());
 var_dump($response->getBody());

9 PURGE Request (Can be used for cache invalidation Eg:: varnish, nginx cache), (*19)

```php use RestService\RestService;, (*20)

$restService = new RestService(); $response = $restService ->setEndpoint('https://jsonplaceholder.typicode.com') ->purge('/posts/1'); ```, (*21)

License

This project is licensed under the MIT License, (*22)

The Versions

21/07 2018

dev-master

9999999-dev

Simple PHP Wrapper class for making REST API calls

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abhilash Pujari

curl php rest http client http client

21/07 2018

dev-dev

dev-dev

Simple PHP Wrapper class for making REST API calls

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abhilash Pujari

curl php rest http client http client

26/04 2018

1.0.x-dev

1.0.9999999.9999999-dev

Simple PHP Wrapper class for making REST API calls

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abhilash Pujari

curl php rest http client http client

26/04 2018

dev-test-travis

dev-test-travis

Simple PHP Wrapper class for making REST API calls

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abhilash Pujari

curl php rest http client http client

26/04 2018

v1.0.5

1.0.5.0

Simple PHP Wrapper class for making REST API calls

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abhilash Pujari

curl php rest http client http client

24/04 2018

v1.0.4

1.0.4.0

Simple PHP Wrapper class for making REST API calls

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abhilash Pujari

curl php rest http client http client

23/04 2018

v1.0.3

1.0.3.0

Simple PHP Wrapper class for making REST API calls

  Sources   Download

MIT

The Requires

 

by Abhilash Pujari

curl php rest http client http client

23/04 2018

v1.0.2

1.0.2.0

Simple PHP Wrapper class for making REST API calls

  Sources   Download

MIT

The Requires

 

by Abhilash Pujari

curl php rest http client http client

22/04 2018

v1.0.1

1.0.1.0

Simple PHP Wrapper class for making REST API calls

  Sources   Download

MIT

The Requires

 

by Abhilash Pujari

curl php rest http client http client

22/04 2018

v1.0

1.0.0.0

Simple PHP Wrapper class for making REST API calls

  Sources   Download

MIT

The Requires

 

by Abhilash Pujari

curl php rest http client http client