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

This package is not auto-updated.

Last update: 2024-12-21 19:49:19 UTC


README

Build Status

web browser with quick browse methods using zf2's HTTP Client and cURL

Installation

Composer:

{
  "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 by www-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'));