tyasa81/requestwrapper is a Laravel package for simple request wrapper.
It currently has 0 GitHub stars and 88 downloads on Packagist (latest version v1.1.2).
Install it with composer require tyasa81/requestwrapper.
Discover more Laravel packages by tyasa81
or browse all Laravel packages to compare alternatives.
Last updated
This is a wrapper for request using Guzzle and Curl. It is mainly used to simplify request code in a request heavy project that deals with cookies and proxy. Facade are made for backward compatiblity on previous project where a lot of static methods are used. Refactoring code into a service class and package are made since it made using Guzzle and Curl much cleaner even for projects that are not cookies or proxy centric.
You can install the package via composer:
composer require tyasa81/requestwrapper
You can publish the config file with:
php artisan vendor:publish --tag="requestwrapper-config"
Using Facades:
use tyasa81\RequestWrapper\Facades\RequestWrapper;
$response = RequestWrapper::getUrl("https://httpbin.org/ip",true);
dd($response);
Available functions:
public static function postUrl($url, $payload, $json=false, &$args=array(), $retry=1, $sleep=1, $timeout=15, $type="POST")
public static function getUrl($url, $json=false, &$args=array(), $retry=1, $sleep=1, $timeout=15)
public static function postMultiPartUrl($url, $multipart, $json=false, &$args=array(), $retry=1, $sleep=1, $timeout=15, $type="POST")
public static function getAsync($url_datas, $json=false, $args=array(), $timeout=15)
public static function UrlwithProxy($url, $json=false, &$args=array(), $proxy_type="FAST", $type="GET", $retry=5, $sleep=0, $timeout=15)
public static function requestCurlProxyRetry($url, $payload, $json=false, &$args=array(), $type="GET", $proxy_type="GLOBAL", $proxy_index=null, $timeout=20,$retry = 4)
public static function requestCurlProxy($url, $payload, $json=false, &$args=array(), $type="GET", $proxy_type="GLOBAL", $proxy_index=null, $timeout=20)
public static function requestCurl($url, $payload, $json=false, &$args=array(), $type="GET", $proxy_type=null, $proxy_index=null, $timeout=15,$retry=0,$sleep=0)
// Helpers Functions
public static function formatCookieJarToString(CookieJar $cookieJar)
public static function getCookieValue(CookieJar $cookieJar, string $cookieName)
public static function convertGuzzleCookieJarToSession(CookieJar $cookieJar)
public static function getCookieJarFromSession(string $session)
Using Service Class:
$curlwrapper = new CurlWrapper(cookieJar: $cookieJar);
$response = $curlwrapper->request(url: "https://httpbin.org/ip", json: true);
OR
$guzzlewrapper = new GuzzleWrapper(cookieJar: $cookieJar);
$response = $guzzlewrapper->request(url: "https://httpbin.org/ip", json: true);
Interface:
request(string $url, $payload=null, bool $json=false, array $headers=array(), string $type="POST", string $proxy_type=null, int $proxy_index=null, int $retry=1, int $sleep=1, int $timeout=15, bool $allow_redirects=null, bool $decode_content=null)
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.