Esempio n. 1
0
Usage: run [--show-class-names] [<script>...]

Reads configuration from caper.yml (see `caper help caperfile`
for more information) and runs 

DOCOPT;
$options = caper_opt_handle($usage);
$cwd = getcwd();
$configFile = "{$cwd}/caper.yml";
if (!file_exists($configFile)) {
    die("Config file not found\n");
}
$showClassNames = $options['--show-class-names'];
$config = \Caper\Config::fromYaml(file_get_contents($configFile), $cwd);
$runner = new \Caper\Trace\Runner();
$parser = new \Caper\Trace\Parser();
caper_header($cli);
scripts:
if ($options['<script>']) {
    foreach ($options['<script>'] as $script) {
        $cli->bold()->cyan()->out("Running script: {$script}")->br();
        $runner->run($config, $script);
    }
} else {
    $cli->bold()->cyan()->out("Running all scripts")->br();
    $runner->runAll($config);
}
parse:
$collector = new \Caper\Stack\Collector($config, $parser);
$cli->br()->bold()->cyan()->out("Parsing trace (this may take a while)")->br();
Esempio n. 2
0
<?php

$usage = <<<'DOCOPT'
Run a PHP script using Caper's trace options

Usage: php [options] run <script> [<args>...]

Options:
  -o, --output=<file>

DOCOPT;
$options = (new \Docopt\Handler(['optionsFirst' => true]))->handle($usage);
$cwd = getcwd();
$output = $options['--output'] ?: $cwd . '/' . uniqid('caper-', true) . '.xt';
if (!($config = caper_config_load($cwd, $_SERVER['HOME'], !!'default'))) {
    die("No config found\n");
}
if (!$_ENV && strpos(ini_get('variables_order'), 'E') === false) {
    throw new \Exception('Please ensure "E" appears in your variables_order ini setting');
}
$runner = new \Caper\Trace\Runner($output);
$script = ['script' => $options['<script>'], 'args' => $options['<args>']];
$runner->scriptPHP($config, $output, $script, $_ENV);