PHP Classes

File: tests/cli/cli-include.php

Recommend this page to a friend!
  Classes of Scott Arciszewski   Chronicle   tests/cli/cli-include.php   Download  
File: tests/cli/cli-include.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Chronicle
Append arbitrary data to a storage container
Author: By
Last change: Concurrent Chronicles

Add support for multiple instances via the ?instance=name parameter.

To implement, add something like this to your local/settings.json in the
instances key:

"public_prefix" => "table_name_prefix"

Then run bin/make-tables.php as normal.

Every instance is totally independent of each other. They have their own

* Clients
* Chain data
* Cross-Signing Targets and Policies
* Replications

If merged, I will document these features and roll it into v1.1.0
Fix CLI tests
Date: 1 year ago
Size: 1,227 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);
namespace
ParagonIE\Chronicle\CliTests;

use
GuzzleHttp\Client;
use
ParagonIE\Chronicle\Chronicle;
use
ParagonIE\EasyDB\EasyDB;
use
ParagonIE\EasyDB\Factory;
use
ParagonIE\Sapient\Adapter\Guzzle;
use
ParagonIE\Sapient\Sapient;
use
GetOpt\{
   
GetOpt,
   
Option
};

require_once
dirname(dirname(__DIR__)) . '/cli-autoload.php';


if (!\
is_readable(CHRONICLE_APP_ROOT . '/local/settings.json')) {
    echo
'Settings are not loaded.', PHP_EOL;
    exit(
1);
}

$settings = \json_decode(
    (string) \
file_get_contents(CHRONICLE_APP_ROOT . '/local/settings.json'),
   
true
);

/** @var EasyDB $db */
$db = Factory::create(
   
$settings['database']['dsn'],
   
$settings['database']['username'] ?? '',
   
$settings['database']['password'] ?? '',
   
$settings['database']['options'] ?? []
);
Chronicle::setDatabase($db);

/**
 * @var GetOpt
 *
 * This defines the Command Line options.
 */
$getopt = new GetOpt([
    new
Option(null, 'base-url', GetOpt::REQUIRED_ARGUMENT)
]);
$getopt->process();
$baseUrl = $getopt->getOption('base-url') ?? 'http://localhost:8080';

$http = new Client();
$sapient = new Sapient(new Guzzle($http));
$serverPublicKey = Chronicle::getSigningKey()->getPublickey();