8000 GitHub - o-kasian/php-http-client: Library for making http requests with php
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

o-kasian/php-http-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#PHP HttpClient

A simple and flexible tool to make HTTP requests from php applications.

###Key features:

  • no curl required, plain sockets only
  • synchronous and asynchronous requests
  • adjustable stream context via stream_context_create makes it possible to use custom certificates per request, by default ssl verification is off
  • easy to use with HTTP proxy. Supports SSL connections through proxy.
  • easy and powerfull api, that helps you to to concentrate on things that are really important.
  • MIT license

###Installation: You can either use composer or include util.php in your app, adding

httpClientAutoLoad($className);

to your __autoload chain, f.ex.

function __autoload($className) {
    if (httpClientAutoLoad($className)) return;
    //Your code here
}
//or use spl_autoload_register
spl_autoload_register('httpClientAutoload');

If you are using composer (not yet available in packagist):

{
    "repositories": [
        {
            "url": "https://github.com/projasource/php-http-client.git",
            "type": "git"
        }
    ],
    "require": {
        "projasource/httpclient": "1.0.0.RC1"
    }
}

###Examples: Basically, any request starts with HttpRequest::build($url). ####Basic Example:

$response = HttpRequest::build("https://example.com")->execute();
var_dump($response->getEntity());

####Proxy Example:

$response = HttpRequest::build("https://example.com")
    ->method("POST")
    ->contentType("application/json")
    ->entity(json_encode($entity))
    ->proxy("http://user:password@192.168.0.1:8080")
    ->accept("application/json")
    ->execute();
echo $response->getEntity()->field;

####Extended SSL example:

$context = stream_context_create();
stream_context_set_option($context, 'ssl', 'cafile', $path);
stream_context_set_option($context, 'ssl', 'verify_host', true);
stream_context_set_option($context, 'ssl', 'verify_peer', true);
stream_context_set_option($context, 'ssl', 'allow_self_signed', true);

$response = HttpRequest::build("https://example.com")
    ->context($context)
    ->execute();

####API Documentation To get api documentation one may use generate-doc make target, or view it online

About

Library for making http requests with php

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0