keep daily currency rates from ČNB
Find a file
Cybervitexus 4d6a7a52b2
Merge pull request #65 from Spoje-NET/dependabot/composer/phpstan/phpstan-2.1.42
composer: bump phpstan/phpstan from 2.1.38 to 2.1.42
2026-03-24 04:41:50 +01:00
.github Bump actions/cache from 4 to 5 2025-12-15 11:24:51 +00:00
bin timer service added 2025-01-26 13:37:48 +01:00
db/migrations project renamed to cnb-cache 2025-01-25 23:25:01 +01:00
debian fix: remove --ipc=host to prevent faked-sysv collision in parallel builds 2026-03-13 12:28:06 +01:00
src Enhance documentation and type hints in ExchangeRate class methods 2025-05-06 22:32:50 +02:00
.gitignore package update 2025-01-26 00:37:43 +01:00
.php-cs-fixer.dist.php Refactor ExchangeRate class for improved readability and consistency 2025-05-06 22:23:40 +02:00
cnb-cache.svg project renamed to cnb-cache 2025-01-25 23:25:01 +01:00
composer.json composer: bump ergebnis/php-cs-fixer-config from 6.58.1 to 6.59.0 2026-02-10 10:14:38 +00:00
composer.lock composer: bump phpstan/phpstan from 2.1.38 to 2.1.42 2026-03-23 11:35:53 +00:00
currency-chooser.png Days to keep is new configuration key 2025-01-26 19:19:19 +01:00
daystokeep.png Days to keep is new configuration key 2025-01-26 19:19:19 +01:00
db.png db screenshot added 2025-01-26 23:43:58 +01:00
example.env v0.1.0 2025-01-22 23:44:23 +01:00
init.png Days to keep is new configuration key 2025-01-26 19:19:19 +01:00
LICENSE Initial commit 2025-01-22 00:23:58 +01:00
Makefile build test install only sqlite package 2025-01-26 20:04:37 +01:00
phinx-adapter.php v0.1.0 2025-01-22 23:44:23 +01:00
phpstan-default-baseline.neon initial commit 2025-01-22 15:19:54 +01:00
phpstan-default.neon.dist initial commit 2025-01-22 15:19:54 +01:00
README.md on request download and store rate when no already present in database 2025-01-29 00:50:16 +01:00
webservers.png Days to keep is new configuration key 2025-01-26 19:19:19 +01:00

CNB cache

cnb-cache

PHP Version License Latest Release

Store daily currency rates in SQL database for given time.

Provide simple API like web interface for stored rates obtaining.

Installation

sudo apt install lsb-release wget apt-transport-https bzip2


wget -qO- https://repo.vitexsoftware.com/keyring.gpg | sudo tee /etc/apt/trusted.gpg.d/vitexsoftware.gpg
echo "deb [signed-by=/etc/apt/trusted.gpg.d/vitexsoftware.gpg]  https://repo.vitexsoftware.com  $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vitexsoftware.list
sudo apt update

sudo apt install cnb-cache-DATABASE

database can be mysql or sqlite

Support the apache2 and lighthttpd web servers:

Web Servers

First Configure the currencies to be cached

Currency Chooser

Then set the days to keep the cache

Days to Keep

And finally the cache is initialized:

Initialization

Data stored in database:

Database

Final configuration is stored in /etc/cnb-cache/cnb-cache.env file

Data Obtaining

After installation the currencies listing is available on the /cnb-cache/ path.

you can use following URL parameters:

{
  "id": 6,
  "date": "2025-01-24",
  "currency": "dolar",
  "amount": 1,
  "code": "USD",
  "rate": 23.958,
  "age": 2
}

The systemd-crond service is started and the cache is updated every day at 0:01 AM

See also: https://github.com/Spoje-NET/pohoda-raiffeisenbank