Esempio n. 1
0
 function test_add9_hook($t)
 {
     $result = "FAIL";
     $app = new App_CLI();
     $app->addHook('beforeObjectInit', function () use(&$result) {
         $result = "OK";
     });
     $t = $app->add('MyObject');
     return $result;
 }
Esempio n. 2
0
<?php

include 'vendor/autoload.php';
$app = new App_CLI();
//$app->pathfinder->addRelativeLocation(['php','shared/lib']);
try {
    $app->add('Logger');
    $app->pathfinder->base_location->addRelativeLocation('shared', ['php' => 'lib', 'addons' => 'addons']);
    if (PHP_SAPI !== 'cli' || !empty($_SERVER['REMOTE_ADDR'])) {
        throw new Exception('Execute from command-line only');
    }
    $options = getopt("k:rha:n:", ['key:', 'reset', 'help', 'addr:', 'name:']);
    if (isset($options['h']) || isset($options['help'])) {
        echo <<<EOF
Usage:

    php bootstrap.php [-k <key> -i <ip> [-n <name>]] [-r] [-h]

    -k, --key <file>
    -a, --addr <addr>
    -n, --name <name>

        Read private key from file and add it as default host. <addr>
        must be also specified. If you omit the name, addr will be used.

    -r, --reset

        Reset user information

    -h, --help