cirelramos/external-request

The External Request is a package to send request to others api-rest .

1.0.3 2023-01-03 20:03 UTC

This package is auto-updated.

Last update: 2024-03-30 00:24:38 UTC


README

Software License

About

The External Request is a package to send request to others api-rest .

Tutorial how create composer package

Installation

Require the cirelramos/external-request package in your composer.json and update your dependencies:

composer require cirelramos/external-request

Configuration

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

Usage

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
);

License

Released under the MIT License, see LICENSE.