2017 © Pedro Peláez
 

library resty

A simple PHP library for doing RESTful HTTP stuff. Does not require the curl extension

image

resty/resty

A simple PHP library for doing RESTful HTTP stuff. Does not require the curl extension

  • Saturday, February 22, 2014
  • by funkatron
  • Repository
  • 19 Watchers
  • 147 Stars
  • 78,079 Installations
  • JavaScript
  • 9 Dependents
  • 4 Suggesters
  • 14 Forks
  • 1 Open issues
  • 7 Versions
  • 6 % Grown

The README.md

Resty.php

A simple PHP library for doing RESTful HTTP stuff. Does not require the curl extension., (*1)

Installation

Use composer to install Resty:, (*2)

  1. Install composer into your project:
curl -s https://getcomposer.org/installer | php

Create a composer.json file in your project root:, (*3)

``` json { "require": { "resty/resty": "@stable" } }, (*4)


Install via composer:

php composer.phar install, (*5)



## Example ``` php <?php require "vendor/autoload.php"; use Resty\Resty; $resty = new Resty(); $resty->setBaseURL('http://httpbin.org/'); $resp = $resty->get('headers'); echo "\n\$resp['status']:\n"; var_dump($resp['status']); echo "\n\$resp['headers']:\n"; var_dump($resp['headers']); echo "\n\$resp['body']:\n"; var_dump($resp['body']); echo "\n\$resp['body_raw']:\n"; var_dump($resp['body_raw']);

Output, (*6)

$resp['status']:
int(200)

$resp['headers']:
array(6) {
  ["Access-Control-Allow-Origin"]=>
  string(1) "*"
  ["Content-Type"]=>
  string(16) "application/json"
  ["Date"]=>
  string(29) "Thu, 13 Feb 2014 15:09:33 GMT"
  ["Server"]=>
  string(15) "gunicorn/0.17.4"
  ["Content-Length"]=>
  string(3) "225"
  ["Connection"]=>
  string(5) "Close"
}

$resp['body']:
object(stdClass)#3 (1) {
  ["headers"]=>
  object(stdClass)#4 (5) {
    ["Host"]=>
    string(11) "httpbin.org"
    ["Connection"]=>
    string(5) "close"
    ["Content-Type"]=>
    string(33) "application/x-www-form-urlencoded"
    ["X-Request-Id"]=>
    string(36) "259dfd8e-6a24-4e77-ae83-9ce50c29ea78"
    ["User-Agent"]=>
    string(11) "Resty 0.6.0"
  }
}

$resp['body_raw']:
string(225) "{
  "headers": {
    "Host": "httpbin.org",
    "Connection": "close",
    "Content-Type": "application/x-www-form-urlencoded",
    "X-Request-Id": "259dfd8e-6a24-4e77-ae83-9ce50c29ea78",
    "User-Agent": "Resty 0.6.0"
  }
}"

Coding Standards

For PHP code, I've decided to adopt the PSR-2 standard., (*7)

To automatically check against the PSR-2 standard in Sublime Text, you can use the Phpcs package or the SumblimeLinter-phpcs plugin. I use the former at the moment. I have the following in Preferences > Package Settings > PHP Code Sniffer Settings - User:, (*8)

{
    "phpcs_executable_path": "/usr/local/Cellar/php55/5.5.8/bin/phpcs",
    "phpcs_additional_args": {
        "--standard": "PSR2",
        "-n": ""
    }
}

Generating API docs

  1. Download phpDocumentor.phar into the root project directory:, (*9)

    curl -O http://phpdoc.org/phpDocumentor.phar
    

    Note: we don't install phpDocumentor with composer to avoid the numerous dependencies it introduces into the project, (*10)

  2. Generate the API docs:, (*11)

    php phpDocumentor.phar -d src/ -t docs/api --template clean
    

The Versions

22/02 2014

dev-master

9999999-dev https://github.com/fictivekin/resty.php

A simple PHP library for doing RESTful HTTP stuff. Does not require the curl extension

  Sources   Download

Apache 2.0

The Requires

  • php >=5.3.0

 

The Development Requires

rest http restful client

13/02 2014

0.6.0

0.6.0.0 https://github.com/fictivekin/resty.php

A simple PHP library for doing RESTful HTTP stuff. Does not require the curl extension

  Sources   Download

Apache 2.0

The Requires

  • php >=5.3.0

 

The Development Requires

rest http restful client

13/09 2012

0.5

0.5.0.0 https://github.com/fictivekin/resty.php

A simple PHP library for doing RESTful HTTP stuff. Does not require the curl extension

  Sources   Download

Apache 2.0

The Requires

  • php >=5.3.0

 

rest http restful client

17/07 2012

0.4.0

0.4.0.0 https://github.com/fictivekin/resty.php

A simple PHP library for doing RESTful HTTP stuff. Does not require the curl extension

  Sources   Download

Apache 2.0

The Requires

  • php >=5.3.0

 

rest http restful client

17/07 2012

0.3.9

0.3.9.0 https://github.com/fictivekin/resty.php

A simple PHP library for doing RESTful HTTP stuff. Does not require the curl extension

  Sources   Download

Apache 2.0

The Requires

  • php >=5.3.0

 

rest http restful client

23/05 2012

0.3.8

0.3.8.0 https://github.com/fictivekin/resty.php

A simple PHP library for doing RESTful HTTP stuff. Does not require the curl extension

  Sources   Download

Apache 2.0

The Requires

  • php >=5.3.0

 

rest http restful client

22/12 2011

0.3.1

0.3.1.0 https://github.com/fictivekin/resty.php

A simple PHP library for doing RESTful HTTP stuff. Does not require the curl extension

  Sources   Download

Apache 2.0

The Requires

  • php >=5.3.0

 

rest http restful client