coingecko-api icon indicating copy to clipboard operation
coingecko-api copied to clipboard

Having an issue with GuzzleHTTP

Open ghost opened this issue 4 years ago • 4 comments

Hello, i'm getting an error when i use this client.

Uncaught Error: Class 'GuzzleHttp\Client' not found in C:\xampp\htdocs\crypto\coingecko_client\src\CoinGeckoClient.php:39

Please help me to solve this Thank you

ghost avatar Dec 26 '20 04:12 ghost

Hello, please install package by composer I hope this helped solve your problem.

codenix-sv avatar Dec 26 '20 11:12 codenix-sv

Still i'm facing the same issue...

ghost avatar Dec 26 '20 14:12 ghost

Sounds like you're wanting to use this as a standalone package (not integrated in your own project) and here's one simple way to do that (examples are geared towards macOS/Linux users but hopefully demonstrate the general idea for Windows too):

  1. Create a new directory and cd into it e.g., mkdir somedir && cd somedir

  2. Create an empty object composer.json file e.g., echo "{}" > composer.json

  3. Now install it using composer e.g., composer require codenix-sv/coingecko-api

  4. Create a new file that uses autoloading e.g., echo "<?php require 'vendor/autoload.php';" > test.php

  5. Now, under that, execute some code... but ensure your require vendor/autoload.php is present first as it magically loads the appropriate classes e.g.,

<?php
require 'vendor/autoload.php';

use Codenixsv\CoinGeckoApi\CoinGeckoClient;

$client = new CoinGeckoClient();
$data = $client->ping();
print_r($data);

Hopefully the output is:

Array
(
    [gecko_says] => (V3) To the Moon!
)

philip avatar May 05 '21 05:05 philip