PHPackages                             petrica/php-ynab4 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. petrica/php-ynab4

ActiveLibrary

petrica/php-ynab4
=================

API to read and write transactions to a YNAB4 json database.

1034PHP

Since Aug 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/petrica/php-ynab4)[ Packagist](https://packagist.org/packages/petrica/php-ynab4)[ RSS](/packages/petrica-php-ynab4/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP YNAB4 Database
==================

[](#php-ynab4-database)

Read and write transactions from and to a YNAB4 JSON database.

Prerequisites
-------------

[](#prerequisites)

- PHP 5.4+
- composer

Quick start
-----------

[](#quick-start)

Clone repository to disk

```
git clone git@github.com:petrica/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
-----------------

[](#read-transactions)

```
# dropbox driver
$io = new YnabDropboxIO(new Client($auth['access_token'], "MTools"));
# or
# 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
------------------

[](#write-transactions)

```
# dropbox driver
$io = new YnabDropboxIO(new Client($auth['access_token'], "MTools"));
# or
# 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();
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/260492d7032fa031e778d060f8d9405ff95bcc80b85a059f3f54fbedfbe80d53?d=identicon)[petrica](/maintainers/petrica)

### Embed Badge

![Health badge](/badges/petrica-php-ynab4/health.svg)

```
[![Health](https://phpackages.com/badges/petrica-php-ynab4/health.svg)](https://phpackages.com/packages/petrica-php-ynab4)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
