PHP code example of akibtanjim / currency-converter

1. Go to this page and download the library: Download akibtanjim/currency-converter 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/ */

    

akibtanjim / currency-converter example snippets

config/app.php


  php artisan make:controller ExampleController



  

  namespace App\Http\Controllers;

  use Illuminate\Http\Request;
  use Currency;

  class ExampleController extends Controller
  {
      public function rates(){
        $response = Currency::getRates();
        return response()->json($response);
      }

      public function single(){
        $response = Currency::convert('USD','BDT',10);
        return response()->json($response);
      }

      public function multiple(){
        $response = Currency::convert('USD',['BDT','JPY','AUD'],10);
        return response()->json($response);
      }
  }

routes/web.php

  php artisan serve