A
A
Alexander Verbitsky2021-09-02 04:35:17
Yii
Alexander Verbitsky, 2021-09-02 04:35:17

How to install extension from gitHub to yii2?

The question seems silly, but I honestly can't figure it out =)))

How to add GuzzleHttp to yii2?

I'm confused by the slash before the class name \ GuzzleHttp. If not for him, I would have thrown everything into "vendor" from GitHub, added alias to extensions.php, and used it. And so, with this slash, it searches not for this alias, but at the root ... I don’t understand where to put all this =) Please explain ....

This is the part of the code where this GuzzleHttp is required

$this->client = new \GuzzleHttp\Client([
            "base_uri" => $baseUrl,
            "headers" => $headers,
            "timeout" => Settings::TIMEOUT_SEC
        ]);


GuzzleHttp itself is at the link: https://github.com/guzzle/guzzle

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Desh, 2021-09-02
@serdesh

Use the "Installing Guzzle" section of your link.
In the console from the project folder, we execute
composer require guzzlehttp/guzzle
Use:

use GuzzleHttp\Client;
$this->client = new Client([
            "base_uri" => $baseUrl,
            "headers" => $headers,
            "timeout" => Settings::TIMEOUT_SEC
        ]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question