The External Request
is a package to send request to others api-rest .
Require the cirelramos/external-request
package in your composer.json
and update your dependencies:
composer require cirelramos/external-request
set provider
'providers' => [
// ...
Cirelramos\ExternalRequest\Providers\ServiceProvider::class,
],
The defaults are set in config/external-request.php
. Publish the config to copy the file to your own config:
php artisan vendor:publish --provider="Cirelramos\ExternalRequest\Providers\ServiceProvider"
Note: this is necessary to you can change default config
use Cirelramos\ExternalRequest\ExternalServiceRequestService;
$baseUri = "yourdomain.com"
$requestPath = "/api/users"
$formParams = [];
$headers = [];
$method = "GET";
$response = ExternalServiceRequestService::execute(
$baseUri,
$method,
$requestPath,
$formParams,
$header
);
$method = "POST";
$formParams = ["username":"cirel", "password":"you"];
$responsePost = ExternalServiceRequestService::execute(
$baseUri,
$method,
$requestPath,
$formParams,
$headers
);
Released under the MIT License, see LICENSE.