tagadvance/stooge

...

Installs: 17

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:project

dev-master 2023-12-10 01:45 UTC

This package is auto-updated.

Last update: 2024-05-10 02:37:13 UTC


README

Build Status

Stooge

A PHP library for simplifying the process of making HTTP requests via cURL.

Stooge performs HTTP requests by using CurlRequest as a fluent builder for PHP's Client URL Library.

  • __invoke() has been overridden to call execute()
  • there are convenience methods for get, post, and put operations
  • autoCookieJar() is useful if sessions are necessary

Download / Install

The easiest way to install Stooge is via Composer:

composer require "tagadvance/stooge:dev-master"
{
    "require": {
        "tagadvance/stooge": "dev-master"
    }
}

Example

<?php

use tagadvance\stooge\CurlRequest;

require_once 'vendor/autoload.php';

$break = str_pad ( $input = '', $pad_length = 5, PHP_EOL );

$url = 'http://intentionallyblankpage.com';
// $url = 'http://intentionallyblankpage.com/redirect.php';
// $url = 'http://intentionallyblankpage.com/test.html';

$request = new CurlRequest ();
$request->autoDetectUserAgent ();
$response = $request
		->autoCookieJar()
		->setAutoreferer ()
		->setReturntransfer ()
		->setConnecttimeout ( 30 )
		->setTimeout ( 30 )
		->setFollowlocation ()
		->setMaxredirs ( 3 )
		->setFreshConnect ()
		->setForbidReuse ()
		->get ( $url );
print $response . $break;

$url = 'http://intentionallyblankpage.com/test.php';
$response = $request->post ( $url, $fields = [ ] );
print $response . $break;

$response = $request->put ( $url, $fields = [ ] );
print $response . PHP_EOL;

What's with the name?

cURL -> Curly Howard -> The Three Stooges -> Stooge