guzwrap: Wrapper to send HTTP requests using Guzzle package

Recommend this page to a friend!
  Info   View files Documentation   View files View files (20)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-07-27 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 20 All time: 10,037 This week: 327Up
Version License PHP version Categories
guzwrap 1.0.0The PHP License5HTTP, PHP 5
Description Author

This package is a wrapper to send HTTP requests using Guzzle package.

It provides a fluent interface to create requests, set request parameters, send requests and retrieve responses. Currently it can:

- Send GET, POST, PUT, DELETE, HEAD, CONNECT, PATCH and OPTIONS requests
- Set request cookies
- Set request the user agent from a list of known browser user agents
- Set file uploads
- Get response headers
- Handle redirections

Picture of Ahmad Mustapha
Name: Ahmad Mustapha <contact>
Classes: 6 packages by
Country: Nigeria Nigeria
Age: ???
All time rank: 363726 in Nigeria Nigeria
Week rank: 42 Up4 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 3x

Details

Guzwrap, PHP GuzzleHttp Wrapper.

Guzwrap is a wrapper that provides easy helper functions around PHP popular web client library, GuzzleHttp.

Installation

Make sure that you have composer installed Composer.

If you don't have Composer run the below command

curl -sS https://getcomposer.org/installer | php

Now, let's install Guzwrap:

composer require ahmard/guzwrap

After installing, require Composer's autoloader in your code:

require 'vendor/autoload.php';

Usage

use Guzwrap\Request;

//simple request
$result = Request::get($url)->exec();

//with authentication
Request::get($url)
    ->auth('username', 'password')
    ->exec();

  • get Guzwrap Instance
    $instance = Request::getInstance();
    //Do something...
    
  • Request with cookies
    Request::get($url)
    ->withCookie()
    //or use cookie file
    ->withCookieFile($fileLocatiom)
    //use cookie session
    ->withCookieSession($name)
    //use array too
    ->withCookieArray([
        'first_name' => 'Jane'
        'other_names' => 'Doe'
    ])->exec();
    
  • Handle redirects
    Request::get($url)
    ->redirects(function($wrp){
        $wrp->max(5);
        $wrp->strict();
        $wrp->referer('http://goo.gl');
        $wrp->protocol('http');
        $wrp->trackRedirects();
        $wrp->onRedirect(function(){
            echo "Redirection detected!";
        });
    })->exec();
    
  • Headers
    Request::get($url)->header(function($h){
    $h->add('hello', 'world');
    $h->add('planet', 'earth');
    })->exec();
    
  • Query
    Request::get('https://google.com')
    ->query('q', 'Who is jane doe')
    ->exec();
    
  • Post form data
    Request::url($url)->post(function($req){
    $req->field('first_name', 'Jane');
    $req->field('last_name', 'Doe');
    })->exec();
    //Post with multipart data
    Request::url($url)->post(function($req){
    $req->field('full_name', 'Jane Doe');
    $req->file('avatar', 'C:\jane_doe.jpg');
    })->exec();
    //Alter file data
    Request::url($url)->post(function($req){
    $req->field('full_name', 'Jane Doe');
    $req->file(function(){
        $file->field('avatar');
        $file->path('C:\jane_doe.jpg');
        $file->name('John_doe.gif');
    });
    })->exec();
    
  • UserAgent
    We provide custom useragents to help send request easily.
    Request::userAgent('chrome');
    //Choose specific useragent index from array
    Request::userAgent('chrome', '1');
    //Choose sub-useragent
    Request::userAgent('chrome', '9.1');
    
  • List useragents
    use Guzwrap\UserAgent;
    $userAgents = (new UserAgent())->getAvailable();
    
  Files folder image Files  
File Role Description
Files folder imagesrc (2 files, 2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageClasses (7 files)
Files folder imagedata (1 directory)
  Plain text file Request.php Class Class source
  Plain text file UserAgent.php Class Class source

  Files folder image Files  /  src  /  Classes  
File Role Description
  Plain text file Cookie.php Class Class source
  Plain text file File.php Class Class source
  Plain text file Header.php Class Class source
  Plain text file Post.php Class Class source
  Plain text file Redirect.php Class Class source
  Plain text file RequestMethods.php Class Class source
  Plain text file TheWrapper.php Class Class source

  Files folder image Files  /  src  /  data  
File Role Description
Files folder imageua (9 files)

  Files folder image Files  /  src  /  data  /  ua  
File Role Description
  Accessible without login Plain text file chrome.json Data Auxiliary data
  Accessible without login Plain text file edge.json Data Auxiliary data
  Accessible without login Plain text file firefox.json Data Auxiliary data
  Accessible without login Plain text file ie.json Data Auxiliary data
  Accessible without login Plain text file mozilla.json Data Auxiliary data
  Accessible without login Plain text file netscape.json Data Auxiliary data
  Accessible without login Plain text file opera.json Data Auxiliary data
  Accessible without login Plain text file phoenix.json Data Auxiliary data
  Accessible without login Plain text file safari.json Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:20
This week:0
All time:10,037
This week:327Up

For more information send a message to info at phpclasses dot org.