PHP code example of ilcleme / cryptocurrencies-laravel

1. Go to this page and download the library: Download ilcleme/cryptocurrencies-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ilcleme / cryptocurrencies-laravel example snippets


namespace App\Http\Controllers;

use IlCleme\Cryptocurrencies\Gateways\Cryptocompare\CryptocomparePriceGateway;

class CryptoController extends Controller
{
    public function getBTCPrice()
    {
        $manager = app('cryptocurrencies.manager');
        /** @var CryptocomparePriceGateway $priceGateway */
        $priceGateway = $manager->getGateway('price');

        //parameters passed to the method are defined in accordance with the Cryptocompare documentation of endpoint
        $parameters = [
            'fsym' => 'BTC',
            'tsyms' => 'USD,JPY,EUR'
        ];
        $result = $priceGateway->getSingleSymbolPrice($parameters);
        return $result;
    }
}

namespace App\Http\Controllers;

use IlCleme\Cryptocurrencies\Gateways\Coinmarketcap\CoinmarketcapGateway;

class CryptoController extends Controller
{
    public function test()
    {
        $manager = app('cryptocurrencies.manager');
        /** @var CoinmarketcapGateway $coinmarketcapGateway */
        $coinmarketcapGateway = $manager->getGateway('coinmarketcap');

        //parameters passed to the method are defined in accordance with the Coinmarketcap documentation of endpoint
        $parameters = [
            'query' => ['id' => '1,2']
        ];
        $result = $coinmarketcapGateway->send('/v1/cryptocurrency/info', 'GET', $parameters);
        return $result;
    }
}

php artisan vendor:publish --provider="IlCleme\\Cryptocurrencies\\Providers\\CryptocurrenciesServiceProvider"