paulovitorbal/php-ynab4
最新稳定版本:2.0.0
Composer 安装命令:
composer require paulovitorbal/php-ynab4
包简介
API to read and write transactions to a YNAB4 json database.
README 文档
README
Read and write transactions from and to a YNAB4 JSON database.
Prerequisites
- PHP 5.4+
- composer
Quick start
Clone repository to disk
git clone git@github.com:paulovitorbal/php-ynab4.git
Run composer install in order to create necessary libraries
cd php-ynab4
composer install
Play with the sample application
cd sample
php index.php
Read transactions
# disk driver if you want to access directly on disk the budget database $io = new YnabDiskIO(); # path to budget folder $pathToBudget = '/app/ynab/Test~B5C2AEE7.ynab4'; # device id as UUID Version 1, if not provided a new device will be generated $deviceId = null; $ynab = new YnabClient($pathToBudget, $io, $deviceId); # fetch transactions from diff files $ynab->pull(); # get latest transactions $transactions = $ynab->getTransactions(); # update device knowledge based on read transactions $ynab->commit(); # store device id for future calls $deviceId = $ynab->getDevice()->getDeviceGUID();
Write transactions
# disk driver if you want to access directly on disk the budget database $io = new YnabDiskIO(); # path to budget folder $pathToBudget = '/app/ynab/Test~B5C2AEE7.ynab4'; # device id as UUID Version 1, if not provided a new device will be generated $deviceId = null; $ynab = new YnabClient($pathToBudget, $io, $deviceId); $transaction = new YnabTransaction(); $transaction->setAccountId('UUID_ACCOUNT_TO_PUSH_TRANSACTION_TO'); $transaction->setAmount('-10.5'); $transaction->setMemo('Some memo'); $transaction->setDate(new \DateTime()); $ynab->setTransactions([ $transaction ]); # Create diff file for other devices to read the new transaction $ynab->push(); # Update device knowledge based on new generated diff file $ynab->commit();
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-02