exit(2);
    }
}
// Setup autoloading
$loader = new Zend\Loader\StandardAutoloader();
$loader->register();
$rules = array('help|h' => 'Get usage message', 'library|l-s' => 'Library to parse; if none provided, assumes current directory', 'output|o-s' => 'Where to write autoload file; if not provided, assumes "autoload_classmap.php" in library directory', 'append|a' => 'Append to autoload file if it exists', 'overwrite|w' => 'Whether or not to overwrite existing autoload file');
try {
    $opts = new Zend\Console\Getopt($rules);
    $opts->parse();
} catch (Zend\Console\Getopt\Exception $e) {
    echo $e->getUsageMessage();
    exit(2);
}
if ($opts->getOption('h')) {
    echo $opts->getUsageMessage();
    exit;
}
$path = $libPath;
if (array_key_exists('PWD', $_SERVER)) {
    $path = $_SERVER['PWD'];
}
$relativePathForClassmap = '';
if (isset($opts->l)) {
    $libraryPath = $opts->l;
    $libraryPath = str_replace('\\', '/', rtrim($libraryPath, '/\\')) . '/';
    if (!is_dir($libraryPath)) {
        echo "Invalid library directory provided" . PHP_EOL . PHP_EOL;
        echo $opts->getUsageMessage();
        exit(2);
    }
Beispiel #2
0
    'library|l-s'   => 'Library to parse; if none provided, assumes current directory',
    'output|o-s'    => 'Where to write plugin map file; if not provided, assumes "plugin_classmap.php" in library directory',
    'append|a'      => 'Append to plugin map file if it exists',
    'overwrite|w'   => 'Whether or not to overwrite existing autoload file',
);

try {
    $opts = new Zend\Console\Getopt($rules);
    $opts->parse();
} catch (Zend\Console\Getopt\Exception $e) {
    echo $e->getUsageMessage();
    exit(2);
}

if ($opts->getOption('h')) {
    echo $opts->getUsageMessage();
    exit();
}

$path = $libPath;
if (array_key_exists('PWD', $_SERVER)) {
    $path = $_SERVER['PWD'];
}

if (isset($opts->l)) {
    $libraryPath = $opts->l;
    $libraryPath = rtrim($libraryPath, '/\\') . DIRECTORY_SEPARATOR;
    if (!is_dir($libraryPath)) {
        echo "Invalid library directory provided" . PHP_EOL . PHP_EOL;
        echo $opts->getUsageMessage();
        exit(2);
    if ($bVerbose) {
        echo $oException . PHP_EOL;
    }
    exit(2);
}
try {
    $oGetopt = new \Zend\Console\Getopt(array('help|h' => 'Get usage message', 'module|m-s' => 'Module path to deploy; if none provided, assumes current directory', 'dir|d-s' => 'Directory path where to deploy the module (ex: apache/www/my-module), the directory could be created if needed', 'modules|a-s' => '(optionnal) Additionnal module namespaces (comma separated) to be used in the application', 'zapp|z-s' => '(optionnal) ZendSkeletonApplication file path, allows locale or remote directory, allows archive (Phar, Rar, Zip) depending on PHP installed libraries', 'composer|c-s' => '(optionnal) Composer.phar file path, allows locale or remote directory', 'overwrite|w' => 'Whether or not to overwrite existing deployed ZendSkeletonApplication', 'verbose|v' => 'Whether or not to display execution trace'));
    $oGetopt->parse();
    $bVerbose = !!$oGetopt->getOption('verbose');
} catch (\Zend\Console\Exception\RuntimeException $oException) {
    $oConsole->writeLine($oException->getUsageMessage());
    exit(2);
}
//Display help
if ($oGetopt->getOption('help')) {
    $oConsole->writeLine($oGetopt->getUsageMessage());
    exit(0);
}
//Perform deployment process
try {
    //Define module to deploy path
    if ($sModulePath = $oGetopt->getOption('module')) {
        if (!is_string($sModulePath)) {
            throw new \InvalidArgumentException('Module directory path expects string, "' . gettype($sModulePath) . '" given');
        }
        if (!is_dir($sModulePath)) {
            throw new \InvalidArgumentException('Module directory path "' . $sModulePath . '" does not exist');
        }
        $sModulePath = realpath($sModulePath);
    } else {
        $sModulePath = getcwd();
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
    require_once __DIR__ . '/vendor/autoload.php';
} else {
    if (file_exists(__DIR__ . '/../../autoload.php')) {
        require_once __DIR__ . '/../../autoload.php';
    } else {
        file_put_contents('php://stderr', 'Failed to load dependencies. Did you run composer install/update?');
    }
}
use Zend\Console\Console;
use Zend\Crypt\Password\Bcrypt;
use Zend\Console\ColorInterface as Color;
$console = Console::getInstance();
// Obtain console params (inspired by https://github.com/weierophinney/changelog_generator/blob/master/changelog_generator.php)
try {
    $opts = new Zend\Console\Getopt(array('help|h' => 'Help', 'text|t-s' => 'Text to hash'));
    $opts->parse();
} catch (Zend\Console\Exception\ExceptionInterface $e) {
    file_put_contents('php://stderr', $e->getUsageMessage());
    exit(1);
}
// Print help message if asked or nothing is asked
if (isset($opts->h) || $opts->toArray() == array()) {
    file_put_contents('php://stdout', $opts->getUsageMessage());
    exit(0);
}
$bcrypt = new Bcrypt();
if (isset($opts->t)) {
    $console->writeLine($bcrypt->create($opts->t), Color::GREEN);
}
function getConfig()
{
    try {
        $opts = new Zend\Console\Getopt(array('help|h' => 'Help; this usage message', 'config|c-s' => 'Configuration file containing base (or all) configuration options', 'token|t-s' => 'GitHub API token', 'user|u-s' => 'GitHub user/organization name', 'repo|r-s' => 'GitHub repository name', 'milestone|m-i' => 'Milestone identifier'));
        $opts->parse();
    } catch (Zend\Console\Exception\ExceptionInterface $e) {
        file_put_contents('php://stderr', $e->getUsageMessage());
        exit(1);
    }
    if (isset($opts->h) || $opts->toArray() == array()) {
        file_put_contents('php://stdout', $opts->getUsageMessage());
        exit(0);
    }
    $config = array('token' => '', 'user' => '', 'repo' => '', 'milestone' => 0);
    if (isset($opts->c)) {
        $userConfig = (include $opts->c);
        if (false === $userConfig) {
            file_put_contents('php://stderr', sprintf("Invalid configuration file specified ('%s')\n", $opts->c));
            exit(1);
        }
        if (!is_array($userConfig)) {
            file_put_contents('php://stderr', sprintf("Configuration file ('%s') did not return an array of configuration\n", $opts->c));
            exit(1);
        }
        $config = array_merge($config, $userConfig);
    }
    if (isset($opts->token)) {
        $config['token'] = $opts->token;
    }
    if (isset($opts->user)) {
        $config['user'] = $opts->user;
    }
    if (isset($opts->repo)) {
        $config['repo'] = $opts->repo;
    }
    if (isset($opts->milestone)) {
        $config['milestone'] = $opts->milestone;
    }
    if (empty($config['token']) || empty($config['user']) || empty($config['repo']) || empty($config['milestone'])) {
        file_put_contents('php://stderr', sprintf("Some configuration is missing; please make sure each of the token, user/organization, repo, and milestone are provided.\nReceived:\n%s\n", var_export($config, 1)));
        exit(1);
    }
    return $config;
}
Beispiel #6
0
        if ($exitCode) {
            printf("\n\nUnit tests for module '%s' failed with status %d. Aborting.\n", $module, $exitCode);
            exit(1);
        } else {
            print "\n";
        }
    } else {
        print "Could not invoke PHPUnit. Aborting.\n";
        exit(1);
    }
}
try {
    $opts = new \Zend\Console\Getopt(array('modules|m=s' => 'comma-separated list of modules to test (case insensitive), test all modules if not set', 'filter|f=s' => 'run only tests whose names match given regex', 'database|d-s' => 'comma-separated list of INI sections with database config (use all sections if empty)', 'coverage|c' => 'generate code coverage report (slow, requires Xdebug extension)'));
    $opts->parse();
    if ($opts->getRemainingArgs()) {
        throw new \Zend\Console\Exception\RuntimeException('Non-option arguments not allowed', $opts->getUsageMessage());
    }
} catch (\Zend\Console\Exception\RuntimeException $e) {
    print $e->getUsageMessage();
    exit(1);
}
// Generate list of available modules.
// The following basic modules are tested first. Other modules are added
// dynamically.
$modulesAvailable = array('Library', 'Database', 'Model');
foreach (new \FilesystemIterator(__DIR__ . '/../module') as $entry) {
    if ($entry->isDir() and !in_array($entry->getFilename(), $modulesAvailable)) {
        $modulesAvailable[] = $entry->getFilename();
    }
}
// Compose list of modules to test