Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 36 | All time: 10,980 This week: 455 |
Version | License | PHP version | Categories | |||
guzwrap 1.2.1 | The PHP License | 7.4 | HTTP, PHP 5 |
Description | Author | |||||||||||||||||||||||
This package is a wrapper to send HTTP requests using Guzzle package. |
|
Guzwrap is a wrapper that provides easy helper functions around PHP popular web client library, GuzzleHttp.
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';
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 (20) |
File | Role | Description | ||
---|---|---|---|---|
src (2 files, 2 directories) | ||||
composer.json | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (20) | / | src |
File | Role | Description | ||
---|---|---|---|---|
Classes (7 files) | ||||
data (1 directory) | ||||
Request.php | Class | Class source | ||
UserAgent.php | Class | Class source |
Files (20) | / | src | / | Classes |
File | Role | Description |
---|---|---|
Cookie.php | Class | Class source |
File.php | Class | Class source |
Header.php | Class | Class source |
Post.php | Class | Class source |
Redirect.php | Class | Class source |
RequestMethods.php | Class | Class source |
TheWrapper.php | Class | Class source |
Files (20) | / | src | / | data | / | ua |
File | Role | Description |
---|---|---|
chrome.json | Data | Auxiliary data |
edge.json | Data | Auxiliary data |
firefox.json | Data | Auxiliary data |
ie.json | Data | Auxiliary data |
mozilla.json | Data | Auxiliary data |
netscape.json | Data | Auxiliary data |
opera.json | Data | Auxiliary data |
phoenix.json | Data | Auxiliary data |
safari.json | Data | Auxiliary data |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.