<?php /** * Create a phar * * @author Cal Evans <*****@*****.**> * @author John Douglass <john .douglass@oit.gatech.edu> */ $getOptLongArray = array("stub:"); $getOptParams = "s:p:v"; $options = getOpt($getOptParams, $getOptLongArray); if (!isset($options['s'], $options['p'])) { echo "You did not specify either a path or a phar file name.\n"; displayHelp(); die(1); } /* * Set up our environment */ $sourceLocation = $options['s']; $pharFile = $options['p']; // At this point, we need to check to see if the file exists. If neither exist, throw exception. if (isset($options['stub'])) { $stubFile = $options['stub']; } else { $stubFile = 'stub.php'; } if (!file_exists($sourceLocation)) { echo "ERROR: Source file location does not exist!\nCheck your source and try again.\n"; displayhelp(); die(1);
<?php require 'ProtobufCompiler/ProtobufParser.php'; if (!debug_backtrace()) { if (!class_exists('\\ProtobufMessage')) { echo $argv[0] . ' requires protobuf extension installed to run' . PHP_EOL; exit(1); } $optionError = false; $useNamespaces = false; $filenamePrefix = false; $outputPsr = false; $iterator = new \RegexIterator(new \ArrayIterator($argv), '/^-/'); $shortOpts = "np:"; $longOpts = array("use-namespaces", "filename-prefix:", "psr"); $options = getOpt($shortOpts, $longOpts); foreach ($options as $key => $value) { switch ($key) { case 'n': case 'use-namespaces': $useNamespaces = true; break; case 'p': case 'filename-prefix': $filenamePrefix = $value; if (strpos($value, '-') === 0) { $optionError = true; } break; case 'psr': $outputPsr = true;
<?php /** * usage * #for test * ./convmv.php --path=/yourpath * #for run * ./convmv.php --path=/yourpath --notest */ ini_set("memory_limit", "256M"); include_once 'vendor/autoload.php'; PMVC\Load::plug(); $params = getOpt('', array('path:', 'exclude:')); $mypath = $params['path']; $exclude = $params['exclude']; if (is_dir($mypath)) { $path = $mypath; } else { $mypath = pathinfo($mypath); $path = $mypath['dirname']; $pattern = $mypath['basename']; } if (empty($path) || !realpath($path)) { exit('No path found' . "\n"); } if (empty($pattern)) { $pattern = '*'; } echo "Run in " . $path . "\n"; echo "File pattern: " . $pattern . "\n"; $files = PMVC\plug('file_list', array('hash' => true, 'prefix' => $path, 'exclude' => $exclude))->ls($path, $pattern);