Simple package for Laravel that makes it easy to send HTTP requests and integrate with web APIs.
soltancode/send-request is a Laravel package for simple package for laravel that makes it easy to send http requests and integrate with web apis..
It currently has 2 GitHub stars and 2.551 downloads on Packagist (latest version v2.0.0).
Install it with composer require soltancode/send-request.
Discover more Laravel packages by soltancode
or browse all Laravel packages to compare alternatives.
Last updated
Simple package for Laravel Framework that makes it easy to send HTTP requests and integrate with web APIs.
composer require soltancode/send-request
use Soltancode\SendRequest\Facades\SendRequest;
// $baseUrl = "https://dummyjson.com";
// $service = "/products/1";
# Using as class:
SendRequest::get($baseUrl, $service);
# Using as helper:
sendRequest()->get($baseUrl, $service)
// $baseUrl = "https://dummyjson.com";
// $service = "/products/1";
// $params = [
// 'q' => 'phone'
// ];
# Using as class:
SendRequest::get($baseUrl, $service, $params); # https://dummyjson.com/products/search?q=phone
# Using as helper:
sendRequest()->get($baseUrl, $service, $params); # https://dummyjson.com/products/search?q=phone
// $baseUrl = "https://api.example.com";
// $service = "/login";
# Using as class:
SendRequest::post($baseUrl, $service, [
'username' => 'myusername',
'password' => 'mypassword'
]);
# Using as helper:
sendRequest()->post($baseUrl, $service, [
'username' => 'myusername',
'password' => 'mypassword'
]);
// $baseUrl = "https://api.example.com";
// $service = "/users/1";
# Using as class:
SendRequest::put($baseUrl, $service, [
'first_name' => 'John',
'last_name' => 'Doe'
]);
# Using as helper:
sendRequest()->put($baseUrl, $service, [
'first_name' => 'John',
'last_name' => 'Doe'
]);
// $baseUrl = "https://api.example.com";
// $service = "/users/1";
# Using as class:
SendRequest::patch($baseUrl, $service, [
'first_name' => 'John'
]);
# Using as helper:
sendRequest()->patch($baseUrl, $service, [
'first_name' => 'John'
]);
// $baseUrl = "https://api.example.com";
// $service = "/users";
# Using as class:
SendRequest::delete($baseUrl, $service, [
'id' => 'John'
]);
# Using as helper:
sendRequest()->delete($baseUrl, $service, [
'id' => 'John'
]);
The timeout method may be used to specify the maximum number of seconds to wait for a response:
$response = sendRequest()->timeout(3)->post(/* ... */);
ReturnResponse - It's a return helper for showing standard json responses.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.