{"id":17343112,"url":"https://github.com/danielme85/laravel-cconverter","last_synced_at":"2025-04-14T00:44:13.042Z","repository":{"id":31872098,"uuid":"35440309","full_name":"danielme85/laravel-cconverter","owner":"danielme85","description":"A simple currency converter plugin for Laravel 5. Currency providers: The European Central Bank, OpenExchange, CurrencyLayer and fixer.io","archived":false,"fork":false,"pushed_at":"2021-02-03T06:30:02.000Z","size":211,"stargazers_count":42,"open_issues_count":4,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T14:55:02.836Z","etag":null,"topics":["currency","currency-converter","currency-exchange-rates","laravel"],"latest_commit_sha":null,"homepage":"https://danielmellum.com/projects/currency-converter","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Strimmerz/IPTV-Extension","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielme85.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-11T17:55:37.000Z","updated_at":"2024-05-28T20:04:39.000Z","dependencies_parsed_at":"2022-08-07T17:00:30.385Z","dependency_job_id":null,"html_url":"https://github.com/danielme85/laravel-cconverter","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielme85%2Flaravel-cconverter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielme85%2Flaravel-cconverter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielme85%2Flaravel-cconverter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielme85%2Flaravel-cconverter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielme85","download_url":"https://codeload.github.com/danielme85/laravel-cconverter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804721,"owners_count":21164127,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["currency","currency-converter","currency-exchange-rates","laravel"],"created_at":"2024-10-15T16:08:25.616Z","updated_at":"2025-04-14T00:44:13.021Z","avatar_url":"https://github.com/danielme85.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Currency Converter\n\n[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/danielme85/laravel-cconverter)\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/danielme85/laravel-cconverter.svg?style=flat-square)](https://packagist.org/packages/danielme85/laravel-cconverter)\n[![GitHub release](https://img.shields.io/github/release/danielme85/laravel-cconverter.svg?style=flat-square)](https://packagist.org/packages/danielme85/laravel-cconverter)\n[![GitHub tag](https://img.shields.io/github/tag/danielme85/laravel-cconverter.svg?style=flat-square)](https://github.com/danielme85/laravel-cconverter)\n[![Travis (.org)](https://img.shields.io/travis/danielme85/laravel-cconverter.svg?style=flat-square)](https://travis-ci.org/danielme85/laravel-cconverter)\n[![Codecov](https://img.shields.io/codecov/c/github/danielme85/laravel-cconverter.svg?style=flat-square)](https://codecov.io/gh/danielme85/laravel-cconverter)\n\nA simple currency conversion plug-in for Laravel 5.5+ 💵\u003cbr\u003e\nExample usage: \u003ca href=\"https://danielmellum.com/projects/currency-converter\" target=\"_blank\"\u003ehttps://danielmellum.com/projects/currency-converter\u003c/a\u003e\n\nVersion testing and requirements\n\n| Version        | Tested with   |\n| :----------:   |:-------------:|\n| dev-master     | Laravel 6.0   |\n| v0.3.*         | Laravel 6.0   |\n| v0.2.*         | Laravel 5.6   | \n| v0.1.*         | Laravel 5.5   | \n| v0.0.7         | Laravel 5.4   | \n\n\u003csmall\u003eIf you are having composer requirement issues using the latest release and Laravel \u003c v5.4, try the v0.0.7 release.\u003c/small\u003e\n\nPlease note:\n* The European Central Bank does not require any user account and is therefore set as the default 'api-source', \nhowever the number of available currencies are somewhat limited compared to the other commercial sources (37). \nIn my experience this source is also unpredictable, and might give an empty response. \n* All the other data providers are commercial and require a user account. They all have a free tier of 1000 requests per month,\n let's say you theoretically cache results for 60 min and you should be covered with some margin for errors 👍 \n Coincidentally Cache is enabled per default and set to 60 min. Now in theory one should perhaps make a simple Eloquent Model with \nthe columns: date, from, to, rate or something similar, and then store the historical results. Please note that depending on usage this \nmight go against the user agreements on the commercial data providers. 🤫 🙈\n\n### Installation\n```\ncomposer require danielme85/laravel-cconverter\n```\n\n### Configuration \nYou can publish this vendor config file if you would like to make changes to the default config.\n```\nphp artisan vendor:publish --provider=\"danielme85\\CConverter\\CConverterServiceProvider\"\n```\n\nAll config variables can also be changed in your local .env file:\n```\nCC_API_SOURCE=eurocentralbank\nCC_USE_SSL=true\nCC_FIXERIO_ACCESS_KEY=\nCC_OPENEXCHANGE_APP_ID=\nCC_CURRENCYLAYER_ACCESS_KEY=\nCC_ENABLE_LOG=false\nCC_ENABLE_CACHE=true\nCC_CACHE_TIMEOUT=60\n```\n \n### Usage\nThere are static class \"shortcuts\" to convert or get one-time Currency series. \n```php\n//To convert a value\n$valueNOK = Currency::conv($from = 'USD', $to = 'NOK', $value = 10, $decimals = 2);\n\n//To convert a value based on historical data\n$valueNOK = Currency::conv($from = 'USD', $to = 'NOK', $value = 10, $decimals = 2, $date = '2018-12-24');\n\n//to get an array of all the rates associated to a base currency.\n$rates = Currency::rates(); //defaults to USD\n\n$rates = Currency::rates('NOK');\n\n//Get historical rates\n$rates = Currency::rates('NOK', '2018-12-24');\n\n```\n\n#### Working with multiple values\nI would highly recommend creating a model instance and the non-static functions getRates() \u0026 convert() when doing \nmultiple conversion or getting multiple currency series for the best performance. The currency rates are stored \nin the provider model by date/base-currency for quick and easy access. \n\n```php\n$currency = new Currency();\n$values = [1, 3, 4, 5...].\nforeach ($values as $value) {\n    $valueNOK = $currency-\u003econvert($from = 'USD', $to = 'NOK', $value = 10, $decimals = 2);\n}\n\n$rates = $currency-\u003egetRates('NOK');\nforeach ($rates as $rate) {\n    $value = $valueNOK * $rate;\n}\n```\n\nYou can override the settings when/if you create a new instance.\n```php\n$currency = new Currency(\n    $api = 'yahoo', \n    $https = false, \n    $useCache = false, \n    $cacheMin = 0);\n...\n$result = Currency:conv(\n    $from = 'USD', \n    $to = 'NOK', \n    $value = 10, \n    $decimals = 2, \n    $date = '2018-12-24', \n    $api = 'yahoo', \n    $https = false, \n    $useCache = false, \n    $cacheMin = 0);\n```\n\nUse the three lettered ISO4217 code for to/from currencies: http://en.wikipedia.org/wiki/ISO_4217\n\n#### Money Formatting\nThe package: gerardojbaez/money is included for an easier and more powerful Money Formatter, excellent alternative to money_format().\nYou can get the values of an conversion by setting round='money' (money formatter overrides rounding).\n```php\nCurrency::conv('USD', 'USD', 10, 2);\n//Result: 10\nCurrency::conv('USD', 'USD', 10, 'money');\n//Result: $10.00\n$currency-\u003econvert('USD', 'USD', 10, 'money');\n//Result: $10.00\n```\nYou can also get the money formatter itself trough the static Currency function:\n```php\n$formater = Currency::money($amount = 0, $currency = 'USD');\n```\nThis Money Formatter also ships with a handy helper function.\n```php\necho moneyFormat(10, 'USD');\n//Result: $10.00\n\n```\nSee Money Formatter github page for more information and usage.\nhttps://github.com/gerardojbaez/money\n\n### Supported functions per API\nDefault API is: The European Central Bank\n\n| Config var        | API                           | HTTPS         | Historical    |  Sign-up required |   URL                         |\n| ----------------- | --------------------------    |:------------: | :---------:   |  :--------------: |   -----------------------     |\n|eurocentralbank    | The European Central Bank     | yes           | yes           |   no              |   https://sdw-wsrest.ecb.europa.eu/help/  |\n|openexchange       | OpenExchangeRates.com         | non-free      | non-free      |   yes             |   https://openexchangerates.org   |\n|currencylayer      | *CurrencyLayer                 | non-free      | yes           |   yes             |   https://currencylayer.com      |\n|fixer              | *Fixer.io                      | yes           | yes           |   yes             |   https://fixer.io               |\n\n\u003ci\u003e*CurrencyLayer and Fixer.io is the same company now, and it seems like the services have become one and the same.\u003c/i\u003e\n\n### Disclaimer\nPlease take note of the Terms of Use for the different data sources.\n\u003cbr\u003e\nhttps://policies.yahoo.com/us/en/yahoo/terms/product-atos/yql/index.htm\n\u003cbr\u003e\nhttps://currencylayer.com/terms\n\u003cbr\u003e\nhttps://openexchangerates.org/terms\n\nThis code is released per the MIT open source license: http://opensource.org/licenses/MIT\nThe actual rates and conversion will vary between the data sources. \nIn addition I am no math professor, so you should probably not use this for super serious multi-billion dollar investments. \nIf you are gonna spend your hard earned billion dollars on the money market, you should probably use something like this: http://www.forex.com/forex.html \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielme85%2Flaravel-cconverter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielme85%2Flaravel-cconverter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielme85%2Flaravel-cconverter/lists"}