{"id":19845229,"url":"https://github.com/rapidwebltd/simple-currency-rates","last_synced_at":"2026-07-22T18:31:29.812Z","repository":{"id":62533305,"uuid":"116402978","full_name":"rapidwebltd/simple-currency-rates","owner":"rapidwebltd","description":"💱 This package provides simple access to current currency exchange rates.","archived":false,"fork":false,"pushed_at":"2026-07-18T02:33:27.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-07-18T04:25:41.888Z","etag":null,"topics":["currency","currency-exchange-rates","currency-rates","library","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rapidwebltd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-05T16:08:59.000Z","updated_at":"2026-07-18T02:31:48.000Z","dependencies_parsed_at":"2022-11-02T15:02:16.894Z","dependency_job_id":null,"html_url":"https://github.com/rapidwebltd/simple-currency-rates","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rapidwebltd/simple-currency-rates","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fsimple-currency-rates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fsimple-currency-rates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fsimple-currency-rates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fsimple-currency-rates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rapidwebltd","download_url":"https://codeload.github.com/rapidwebltd/simple-currency-rates/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapidwebltd%2Fsimple-currency-rates/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35773465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-22T02:00:06.236Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-exchange-rates","currency-rates","library","php"],"created_at":"2024-11-12T13:06:56.360Z","updated_at":"2026-07-22T18:31:29.805Z","avatar_url":"https://github.com/rapidwebltd.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Currency Rates\n\nSimple Currency Rates provides current fiat and Bitcoin exchange rates through a small, framework-independent PHP API. It supports PHP 5.6 through current PHP releases.\n\nBy default, fiat rates come from the keyless [Frankfurter API](https://frankfurter.dev/) and Bitcoin rates come from [Blockchain.com](https://www.blockchain.com/explorer/api/exchange_rates_api). Responses are cached on the local filesystem.\n\n## Installation\n\n```bash\ncomposer require rapidwebltd/simple-currency-rates\n```\n\n## Usage\n\n```php\nuse RapidWeb\\SimpleCurrencyRates\\SimpleCurrencyRates;\n\n$rates = (new SimpleCurrencyRates())-\u003eget('GBP');\n```\n\nThe base currency is normalised to uppercase and always has a rate of `1.0`. Rates are returned as a currency-code-keyed array sorted alphabetically:\n\n```php\n[\n    'EUR' =\u003e 1.16,\n    'GBP' =\u003e 1.0,\n    'USD' =\u003e 1.35,\n    'XBT' =\u003e 0.00001234,\n]\n```\n\nThe base must be a three-letter currency code. Network failures and invalid provider responses throw `RateSourceException` instead of returning incomplete data.\n\n## Using another cache\n\nThe constructor and `setCache()` accept PSR-16 caches, PSR-6 cache pools, and compatible objects exposing `get`, `set`, and optionally `has`. No PSR package is forced on applications that use the built-in cache.\n\n```php\n$rates = new SimpleCurrencyRates($psr16Cache);\n\n// Or replace it later.\n$rates-\u003esetCache($psr6CachePool);\n```\n\nTo change the built-in cache directory:\n\n```php\nuse RapidWeb\\SimpleCurrencyRates\\Cache\\FilesystemCache;\n\n$rates = new SimpleCurrencyRates(\n    new FilesystemCache('/var/cache/my-application/currency-rates')\n);\n```\n\n## Using custom rate sources\n\nA source implements `RateSourceInterface` and returns positive rates keyed by three-letter currency code. `getCacheTtl()` returns its cache lifetime in seconds; return `0` to disable caching.\n\n```php\nuse RapidWeb\\SimpleCurrencyRates\\Contracts\\RateSourceInterface;\n\nclass CompanyRateSource implements RateSourceInterface\n{\n    public function getRates($base)\n    {\n        return [\n            'EUR' =\u003e 1.16,\n            'USD' =\u003e 1.35,\n        ];\n    }\n\n    public function getCacheTtl()\n    {\n        return 300;\n    }\n}\n```\n\nPass sources as the second constructor argument, replace them with `setSources()`, or append one with `addSource()`:\n\n```php\n$rates = new SimpleCurrencyRates($cache, [\n    new CompanyRateSource(),\n]);\n\n$rates\n    -\u003esetSources([new CompanyRateSource()])\n    -\u003eaddSource($anotherSource);\n```\n\nWhen multiple sources return the same currency, the later source wins. The requested base currency is always reset to `1.0`.\n\nThe bundled `FrankfurterRateSource` and `BlockchainBitcoinRateSource` accept an optional callable HTTP client, which is useful for application-specific transports and deterministic tests:\n\n```php\nuse RapidWeb\\SimpleCurrencyRates\\Sources\\FrankfurterRateSource;\n\n$source = new FrankfurterRateSource(function ($url) use ($httpClient) {\n    return $httpClient-\u003eget($url)-\u003egetBody()-\u003egetContents();\n});\n```\n\n## Testing\n\n```bash\ncomposer install\nvendor/bin/phpunit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidwebltd%2Fsimple-currency-rates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapidwebltd%2Fsimple-currency-rates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidwebltd%2Fsimple-currency-rates/lists"}