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

Installs: 147 613

Dependents: 8

Suggesters: 4

Security: 0

Stars: 144

Watchers: 19

Forks: 13

Open Issues: 1


0.6.0 2014-02-13 16:19 UTC

This package is not auto-updated.

Last update: 2021-10-15 22:51:09 UTC


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


Use composer to install Resty:

  1. Install composer into your project:
curl -s | php

Create a composer.json file in your project root:

    "require": {
        "resty/resty": "@stable"

Install via composer:

php composer.phar install


require "vendor/autoload.php";

use Resty\Resty;

$resty = new Resty();
$resp = $resty->get('headers');

echo "\n\$resp['status']:\n";

echo "\n\$resp['headers']:\n";

echo "\n\$resp['body']:\n";

echo "\n\$resp['body_raw']:\n";



array(6) {
  string(1) "*"
  string(16) "application/json"
  string(29) "Thu, 13 Feb 2014 15:09:33 GMT"
  string(15) "gunicorn/0.17.4"
  string(3) "225"
  string(5) "Close"

object(stdClass)#3 (1) {
  object(stdClass)#4 (5) {
    string(11) ""
    string(5) "close"
    string(33) "application/x-www-form-urlencoded"
    string(36) "259dfd8e-6a24-4e77-ae83-9ce50c29ea78"
    string(11) "Resty 0.6.0"

string(225) "{
  "headers": {
    "Host": "",
    "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.

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:

    "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:
curl -O

Note: we don't install phpDocumentor with composer to avoid the numerous dependencies it introduces into the project

  1. Generate the API docs:
php phpDocumentor.phar -d src/ -t docs/api --template clean