PHP code example of martian / euro-currency-exchange

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

    

martian / euro-currency-exchange example snippets


// config/app.php

'providers' => [
    ...
    Martian\EuroCurrencyExchange\Providers\EuroCurrencyExchangeServiceProvider::class,
];

// config/euro-currency-exchange.php

return [
    'route' => 'your-custom-route',
];

// routes/api.php

use Martian\EuroCurrencyExchange\Http\Controllers\EuroCurrencyExchangeController;

Route::get('your-custom-route', EuroCurrencyExchangeController::class);

// app/Http/Controllers/YourCustomController.php

use Martian\EuroCurrencyExchange\Classes\Builder;

class YourCustomController extends Controller
{
    public function __invoke(Request $request)
    {
        $builder = new Builder($request->amount, $request->to);

        // Do something with the builder, check the provided methods in the Builder class.
        return response()->json([
            'amount' => $builder->getAmount(),
            'from' => $builder->getCurrency(),
            'to' => $builder->getConvertedCurrency(),
            'rate' => $builder->getRate(),
            'converted' => $builder->getConvertedAmount(),
        ]);
    }
}
bash
php artisan vendor:publish --provider="Martian\EuroCurrencyExchange\Providers\EuroCurrencyExchangeServiceProvider" --tag="config"