PHP Classes

PHP Currency Converter API: Provides an API to return currency exchange rates

Recommend this page to a friend!
  Info   View files Example   View files View files (41)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 132 This week: 1All time: 9,314 This week: 560Up
Version License PHP version Categories
currencyexchangeapi 1.0.0Custom (specified...5PHP 5, Web services, Finances
Description 

Author

This package provides an API to return currency exchange rates.

It implements a REST API server that can process requests to perform several types of operations with currencies. Currently it can:

- Return the exchange rate between two given currencies
- Update the rate between a given currency and the Euro
- Delete the current exchange rate of a given currency

Innovation Award
PHP Programming Innovation award nominee
December 2019
Number 6
Many applications need to deal with different currencies used in payments that they may take, so they may need to convert money amounts between different currencies.

Often those applications use remote APIs that rely on remote exchange conversion APIs to work well.

If for some reason those APIs may not be reachable when the application needs to use the conversion exchange rate values, the application may fail to operate, thus leading to eventual financial losses.

This package provides a more reliable alternative based on its own API to obtain the conversion exchange rates, thus avoiding to rely so much on external APIs.

Manuel Lemos
Picture of Manolo Salsas
  Performance   Level  
Name: Manolo Salsas <contact>
Classes: 9 packages by
Country: Spain Spain
Age: 42
All time rank: 306878 in Spain Spain
Week rank: 411 Up13 in Spain Spain Up
Innovation award
Innovation award
Nominee: 6x

Winner: 1x

Example

<?php

use App\Kernel;
use
Symfony\Component\Debug\Debug;
use
Symfony\Component\HttpFoundation\Request;

require
dirname(__DIR__).'/config/bootstrap.php';

if (
$_SERVER['APP_DEBUG']) {
   
umask(0000);

   
Debug::enable();
}

if (
$trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
   
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}

if (
$trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
   
Request::setTrustedHosts([$trustedHosts]);
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);


Details

Currency exchange REST API Build Status

Currency exchange is a REST API made with Symfony.

Documentation

GET /currency/{currencyFrom}/{currencyTo}/?number=number
example: GET /currency/eur/dol/?number=3.45

POST /currency/{currency}
parameters: json => {rateToEur, symbol}
example: POST /currency/eur with {rateToEur: 1, symbol: "?"}

PUT /currency/{currency}
parameters: json => {rateToEur, symbol}
example: PUT /currency/eur with {rateToEur: 1, symbol: "eur"}

DELETE /currency/{currency}
example: DELETE /currency/eur

Installation

git clone https://github.com/msalsas/currency-exchange.git

cd currency-exchange

composer install

php bin/console doctrine:database:create

php bin/console doctrine:database:create --env=test

php bin/console doctrine:migrations:migrate

php bin/console doctrine:migrations:migrate --env=test

symfony server:start 

you will need:

- The Symfony installer

- php-sqlite3 as database is sqlite by default

Testing

php ./bin/phpunit

License

This bundle is under the MIT license. See the complete license in the bundle

Reporting an issue or a feature request

Issues and feature requests are tracked in the Github issue tracker.


  Files folder image Files  
File Role Description
Files folder imagebin (2 files)
Files folder imageconfig (4 files, 2 directories)
Files folder imagepublic (1 file)
Files folder imagesrc (1 file, 6 directories)
Files folder imagetests (2 directories)
Accessible without login Plain text file .env Data Auxiliary data
Accessible without login Plain text file .env.test Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file symfony.lock Data Auxiliary data

  Files folder image Files  /  bin  
File Role Description
  Plain text file console Class Class source
  Accessible without login Plain text file phpunit Data Auxiliary data

  Files folder image Files  /  config  
File Role Description
Files folder imagepackages (6 files, 3 directories)
Files folder imageroutes (1 file)
  Plain text file bootstrap.php Class Class source
  Plain text file bundles.php Class Class source
  Accessible without login Plain text file routes.yaml Data Auxiliary data
  Accessible without login Plain text file services.yaml Data Auxiliary data

  Files folder image Files  /  config  /  packages  
File Role Description
Files folder imagedev (2 files)
Files folder imageprod (2 files)
Files folder imagetest (3 files)
  Accessible without login Plain text file cache.yaml Data Auxiliary data
  Accessible without login Plain text file doctrine.yaml Data Auxiliary data
  Accessible without login Plain text file doctrine_migrations.yaml Data Auxiliary data
  Accessible without login Plain text file framework.yaml Data Auxiliary data
  Accessible without login Plain text file jms_serializer.yaml Data Auxiliary data
  Accessible without login Plain text file routing.yaml Data Auxiliary data

  Files folder image Files  /  config  /  packages  /  dev  
File Role Description
  Accessible without login Plain text file jms_serializer.yaml Data Auxiliary data
  Accessible without login Plain text file routing.yaml Data Auxiliary data

  Files folder image Files  /  config  /  packages  /  prod  
File Role Description
  Accessible without login Plain text file doctrine.yaml Data Auxiliary data
  Accessible without login Plain text file jms_serializer.yaml Data Auxiliary data

  Files folder image Files  /  config  /  packages  /  test  
File Role Description
  Accessible without login Plain text file doctrine.yaml Data Auxiliary data
  Accessible without login Plain text file framework.yaml Data Auxiliary data
  Accessible without login Plain text file routing.yaml Data Auxiliary data

  Files folder image Files  /  config  /  routes  
File Role Description
  Accessible without login Plain text file annotations.yaml Data Auxiliary data

  Files folder image Files  /  public  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  src  
File Role Description
Files folder imageController (1 file)
Files folder imageEntity (2 files)
Files folder imageException (1 file)
Files folder imageMigrations (1 file)
Files folder imageRepository (2 files)
Files folder imageService (1 file)
  Plain text file Kernel.php Class Class source

  Files folder image Files  /  src  /  Controller  
File Role Description
  Plain text file CurrencyRateController.php Class Class source

  Files folder image Files  /  src  /  Entity  
File Role Description
  Plain text file CurrencyRate.php Class Class source
  Plain text file CurrencyRateInterface.php Class Class source

  Files folder image Files  /  src  /  Exception  
File Role Description
  Plain text file CurrencyRateException.php Class Class source

  Files folder image Files  /  src  /  Migrations  
File Role Description
  Plain text file Version20190723191557.php Class Class source

  Files folder image Files  /  src  /  Repository  
File Role Description
  Plain text file CurrencyRateRepository.php Class Class source
  Plain text file CurrencyRateRepositoryInterface.php Class Class source

  Files folder image Files  /  src  /  Service  
File Role Description
  Plain text file CurrencyRateService.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageRepository (2 files)
Files folder imageService (1 file)

  Files folder image Files  /  tests  /  Repository  
File Role Description
  Plain text file AbstractCurrencyRateRepositoryTest.php Class Class source
  Plain text file CurrencyRateRepositoryTest.php Class Class source

  Files folder image Files  /  tests  /  Service  
File Role Description
  Plain text file CurrencyRateServiceTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:132
This week:1
All time:9,314
This week:560Up