yalesov / zf2-browser
web browser with quick browse methods using zf2's HTTP Client and cURL
v2.1.3
2016-07-06 12:26 UTC
Requires
- php: >=5.3.3
- yalesov/arg-validator: 2.*
- zendframework/zend-http: 2.*
Requires (Dev)
README
web browser with quick browse methods using zf2's HTTP Client and cURL
Installation
{ "require": { "yalesov/zf2-browser": "2.*" } }
Copy config/browser.local.php.dist
into (app root)/config/autoload/browser.local.php
, and edit configs as described below.
Config
The browser
alias can be changed to anything you like.
cookieDir
: directory for storing cookies. Make sure you create this directory, and that it is writable bywww-data
(or whatever your PHP scripts run as); or at least that its parent directory is writable (the script will create this dir for you in this case).cookieLife
: lifetime for cookie files (minute)connectTimeout
: max time to wait when connecting (second)options
: wrapper for\Zend\Http\Client::setOptions()
headers
: wrapper for\Zend\Http\Client::setHeaders()
Usage
Get a browser instance
// $locator instanceof ServiceLocator $browser = $locator->get('browser')->newInstance();
GET
a page
$responseBody = $browser->get('http://example.com');
POST
to a page with param foo
= bar
$responseBody = $browser->post('http://example.com', array('foo' => 'bar'));