[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/httpful/ -> README.md (source)

   1  # Httpful
   2  
   3  [![Build Status](https://secure.travis-ci.org/nategood/httpful.png?branch=master)](http://travis-ci.org/nategood/httpful)
   4  
   5  [Httpful](http://phphttpclient.com) is a simple Http Client library for PHP 5.3+.  There is an emphasis of readability, simplicity, and flexibility – basically provide the features and flexibility to get the job done and make those features really easy to use.
   6  
   7  Features
   8  
   9   - Readable HTTP Method Support (GET, PUT, POST, DELETE, HEAD, PATCH and OPTIONS)
  10   - Custom Headers
  11   - Automatic "Smart" Parsing
  12   - Automatic Payload Serialization
  13   - Basic Auth
  14   - Client Side Certificate Auth
  15   - Request "Templates"
  16  
  17  # Sneak Peak
  18  
  19  Here's something to whet your appetite.  Search the twitter API for tweets containing "#PHP".  Include a trivial header for the heck of it.  Notice that the library automatically interprets the response as JSON (can override this if desired) and parses it as an array of objects.
  20  
  21      $url = "http://search.twitter.com/search.json?q=" . urlencode('#PHP');
  22      $response = Request::get($url)
  23          ->withXTrivialHeader('Just as a demo')
  24          ->send();
  25  
  26      foreach ($response->body->results as $tweet) {
  27          echo "@{$tweet->from_user} tweets \"{$tweet->text}\"\n";
  28      }
  29  
  30  # Installation
  31  
  32  ## Phar
  33  
  34  A [PHP Archive](http://php.net/manual/en/book.phar.php) (or .phar) file is available for [downloading](https://github.com/nategood/httpful/downloads).  Simply [download](https://github.com/nategood/httpful/downloads) the .phar, drop it into your project, and include it like you would any other php file.  _This method is ideal smaller projects, one off scripts, and quick API hacking_.
  35  
  36      <?php
  37      include('httpful.phar');
  38      $r = \Httpful\Request::get($uri)->sendIt();
  39      ...
  40  
  41  ## Composer
  42  
  43  Httpful is PSR-0 compliant and can be installed using [composer](http://getcomposer.org/).  Simply add `nategood/httpful` to your composer.json file.  _Composer is the sane alternative to PEAR.  It is excellent for managing dependancies in larger projects_.
  44  
  45      {
  46          "require": {
  47              "nategood/httpful": "*"
  48          }
  49      }
  50  
  51  ## Install from Source
  52  
  53  Because Httpful is PSR-0 compliant, you can also just clone the Httpful repository and use a PSR-0 compatible autoloader to load the library, like [Symfony's](http://symfony.com/doc/current/components/class_loader.html). Alternatively you can use the PSR-0 compliant autoloader included with the Httpful (simply `require("bootstrap.php")`).
  54  
  55  # Show Me More!
  56  
  57  You can checkout the [Httpful Landing Page](http://phphttpclient.com) for more info including many examples and  [documentation](http:://phphttpclient.com/docs).
  58  
  59  # Contributing
  60  
  61  Httpful highly encourages sending in pull requests.  When submitting a pull request please:
  62  
  63   - All pull requests should target the `dev` branch (not `master`)
  64   - Make sure your code follows the [coding conventions](http://pear.php.net/manual/en/standards.php)
  65   - Please use soft tabs (four spaces) instead of hard tabs
  66   - Make sure you add appropriate test coverage for your changes
  67   - Run all unit tests in the test directory via `phpunit ./tests`
  68   - Include commenting where appropriate and add a descriptive pull request message
  69  
  70  # Changelog
  71  
  72  ## 0.2.3
  73  
  74   - FIX Overriding default Mime Handlers
  75   - FIX [PR #73](https://github.com/nategood/httpful/pull/73) Parsing http status codes
  76  
  77  ## 0.2.2
  78  
  79   - FEATURE Add support for parsing JSON responses as associative arrays instead of objects
  80   - FEATURE Better support for setting constructor arguments on Mime Handlers
  81  
  82  ## 0.2.1
  83  
  84   - FEATURE [PR #72](https://github.com/nategood/httpful/pull/72) Allow support for custom Accept header
  85  
  86  ## 0.2.0
  87  
  88   - REFACTOR [PR #49](https://github.com/nategood/httpful/pull/49) Broke headers out into their own class
  89   - REFACTOR [PR #54](https://github.com/nategood/httpful/pull/54) Added more specific Exceptions
  90   - FIX [PR #58](https://github.com/nategood/httpful/pull/58) Fixes throwing an error on an empty xml response
  91   - FEATURE [PR #57](https://github.com/nategood/httpful/pull/57) Adds support for digest authentication
  92  
  93  ## 0.1.6
  94  
  95   - Ability to set the number of max redirects via overloading `followRedirects(int max_redirects)`
  96   - Standards Compliant fix to `Accepts` header
  97   - Bug fix for bootstrap process when installed via Composer
  98  
  99  ## 0.1.5
 100  
 101   - Use `DIRECTORY_SEPARATOR` constant [PR #33](https://github.com/nategood/httpful/pull/32)
 102   - [PR #35](https://github.com/nategood/httpful/pull/35)
 103   - Added the raw\_headers property reference to response.
 104   - Compose request header and added raw\_header to Request object.
 105   - Fixed response has errors and added more comments for clarity.
 106   - Fixed header parsing to allow the minimum (status line only) and also cater for the actual CRLF ended headers as per RFC2616.
 107   - Added the perfect test Accept: header for all Acceptable scenarios see  @b78e9e82cd9614fbe137c01bde9439c4e16ca323 for details.
 108   - Added default User-Agent header
 109    - `User-Agent: Httpful/0.1.5` + curl version + server software + PHP version
 110   - To bypass this "default" operation simply add a User-Agent to the request headers even a blank User-Agent is sufficient and more than simple enough to produce me thinks.
 111   - Completed test units for additions.
 112   - Added phpunit coverage reporting and helped phpunit auto locate the tests a bit easier.
 113  
 114  ## 0.1.4
 115  
 116   - Add support for CSV Handling [PR #32](https://github.com/nategood/httpful/pull/32)
 117  
 118  ## 0.1.3
 119  
 120   - Handle empty responses in JsonParser and XmlParser
 121  
 122  ## 0.1.2
 123  
 124   - Added support for setting XMLHandler configuration options
 125   - Added examples for overriding XmlHandler and registering a custom parser
 126   - Removed the httpful.php download (deprecated in favor of httpful.phar)
 127  
 128  ## 0.1.1
 129  
 130   - Bug fix serialization default case and phpunit tests
 131  
 132  ## 0.1.0
 133  
 134   - Added Support for Registering Mime Handlers
 135    - Created AbstractMimeHandler type that all Mime Handlers must extend
 136    - Pulled out the parsing/serializing logic from the Request/Response classes into their own MimeHandler classes
 137    - Added ability to register new mime handlers for mime types


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1