gianarb/zf2-psysh-module

View on GitHub
bin/zf2-psysh

Summary

Maintainability
Test Coverage
#!/usr/bin/env php
<?php
use Psy\Shell;
use Zend\Mvc\Application;
use Psy\Configuration;

chdir(__DIR__);
$previousDir = '.';
while (!file_exists('config/application.config.php')) {
    $dir = dirname(getcwd());
    if ($previousDir === $dir) {
        throw new RuntimeException(
            'Unable to locate "config/application.config.php": ' .
            'is PsyshModule in a subdir of your application skeleton?'
        );
    }
    $previousDir = $dir;
    chdir($dir);
}
if (is_readable('init_autoloader.php')) {
    include_once 'init_autoloader.php';
} elseif (file_exists(__DIR__ . '/../vendor/autoload.php')) {
    include_once __DIR__ . '/../vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../../autoload.php')) {
    include_once __DIR__ . '/../../../autoload.php';
} else {
    throw new RuntimeException('Error: vendor/autoload.php could not be found. Did you run php composer.phar install?');
}
$application = Application::init(include 'config/application.config.php');
$application->bootstrap();

$psyConfiguration = new Configuration($application->getConfig()['psysh']);
$psyShell = new Shell($psyConfiguration);
$psyShell->setScopeVariables($application->run());
$psyShell->run();
extract($psyShell->getScopeVariables());