Answer the question
In order to leave comments, you need to log in
Is there an alternative to Guzzle for requests to external apis or how to properly include it in your package?
Actually the subject ...
I already have a sports interest ... a powerful framework, but for each iteration you still need to install a bunch of things that are often incompatible with each other ((
The task is banal to the point of impossibility - to send a get request to a third-party api and get a response.
It only turned out via Guzzle.But when installing it, another 20 megabytes of any slag was installed...
Update: If there
is no alternative...
then
how to connect this Guzzle only to your package
? you need to write require 'vendor/autoloader.php'; - where??
Maybe something else needs to be added to app/config.php?
Now the structure is as follows
packages:
dkweb
mypackage
src
http
Controllers
RestClient.php
MypackageServiceProvider.php
vendor
guzzlehttp
config
composer.json
<?php
namespace Dkweb\Mypackage\Http\Controllers;
use GuzzleHttp\Client;
class RestClient
{
protected function request($apiCall, $params = array())
{
$client = new Client([
'base_uri' => $this->apiUrl.$apiCall
]);
return $client->request('GET','?Id=48&appKey=60');
}
}
Answer the question
In order to leave comments, you need to log in
I already have a sporting interest ... a powerful framework, but for each iteration you still need to install a bunch of things that are often incompatible with each other
The simplest GET requests can be made through
If you need something more convenient and customizable, there is a good and intuitive nategood/httpful package
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question