PHP code example of pdapps / kanbani-data

1. Go to this page and download the library: Download pdapps/kanbani-data library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pdapps / kanbani-data example snippets


// Creating a sync file from scratch:
$syncData = new Kanbani\SyncData;
$syncData->boards = [$board1, $board2, ...];
$syncData->serializeFile('foobar.kanbani');
// Or, encrypted:
$syncData->serializeFile('foobar.kanbani', "TheSecretString");

// Reading an existing sync file:
$syncData = new Kanbani\SyncData;
$syncData->unserializeFile('foobar.kanbani');
// Or, if encrypted:
$syncData->unserializeFile('foobar.kanbani', "TheSecretString", "sOmOzK...");
echo count($syncData->boards);

// Can also chain like so:
$syncData = (new Kanbani\SyncData($boards))
    ->serializeFile(...);

$syncData = (new Kanbani\SyncData)
    ->unserializeFile(...);

// Get plain text JSON:
// {"sync_version": 1, "client_version": 1, "boards": [...]}
echo json_encode($syncData);

// Get CSV (to read back CSV use Kanbani Web Viewer's import plugin):
// board;agEi...P4F7;1577836800000;"Welcome Board";
echo $syncData->serializeToCSV();

// Creating a sync file from scratch:
$data = json_encode($object);
(new Kanbani\SyncFile)->serializeFile("foobar.kanbani", $data);

// Reading an existing sync file:
$sync = (new Kanbani\SyncFile)->unserializeFile("foobar.kanbani");
$object = json_decode($sync->data);

// Reading file info only (faster, doesn't parse the data):
$syncFile = (new Kanbani\SyncFile)->unserializeHeader(file_get_contents(...));
echo $syncFile->isEncrypted() ? "Encrypted data" : "Plain text";

$syncFile = new Kanbani\SyncFile;
$syncFile->secret = "TheSecretString";
$syncFile->boardID = "sOmOzK...";
echo $syncFile->encryptedFileName(), ".kanbani";

$syncData->serializeToJSON();       // plain text JSON
$syncData->serializeToCSV();        // CSV format similar to Trello
$syncData->serializeToExcelCSV();   // CSV compatible with MS Excel

$qrCode = new Kanbani\QrCodeData;
$qrCode->title = "Generated sync profile";

$baseURL = "https://deep.secret/kanbani/";
$auth = new Kanbani\QrCodePassword("PDApps", "4Ever!");
$qrCode->transport = new Kanbani\QrCodeSFTP($baseURL, $auth);

$data = json_encode($qrCode);

// $data can now be encoded as an image:

$qrCode = new Kanbani\QrCodeData;
$qrCode->unserialize(json_decode($data));
echo $qrCode->title;
echo get_class($qrCode->transport);

$dav = new QrCodeWebDAV("https://dav.user.pdapps.org", null /*no auth*/);
$error = $dav->testConnection();
if ($error) {
    echo "Problem '$error[0]': $error[1]";
} else {
    echo "Connection test OK!";
}