本文整理汇总了PHP中Console::writeLine方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::writeLine方法的具体用法?PHP Console::writeLine怎么用?PHP Console::writeLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Console
的用法示例。
在下文中一共展示了Console::writeLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* Start server
*
* @param string[] args
*/
public static function main(array $args)
{
$stor = new TestingStorage();
$stor->add(new TestingCollection('/', $stor));
$stor->add(new TestingCollection('/.trash', $stor));
$stor->add(new TestingElement('/.trash/do-not-remove.txt', $stor));
$stor->add(new TestingCollection('/htdocs', $stor));
$stor->add(new TestingElement('/htdocs/file with whitespaces.html', $stor));
$stor->add(new TestingElement('/htdocs/index.html', $stor, "<html/>\n"));
$stor->add(new TestingCollection('/outer', $stor));
$stor->add(new TestingCollection('/outer/inner', $stor));
$stor->add(new TestingElement('/outer/inner/index.html', $stor));
$auth = newinstance('lang.Object', array(), '{
public function authenticate($user, $password) {
return ("testtest" == $user.$password);
}
}');
$protocol = newinstance('peer.ftp.server.FtpProtocol', array($stor, $auth), '{
public function onShutdown($socket, $params) {
$this->answer($socket, 200, "Shutting down");
$this->server->terminate= TRUE;
}
}');
isset($args[0]) && $protocol->setTrace(Logger::getInstance()->getCategory()->withAppender(new FileAppender($args[0])));
$s = new Server('127.0.0.1', 0);
try {
$s->setProtocol($protocol);
$s->init();
Console::writeLinef('+ Service %s:%d', $s->socket->host, $s->socket->port);
$s->service();
Console::writeLine('+ Done');
} catch (Throwable $e) {
Console::writeLine('- ', $e->getMessage());
}
}
示例2: getPageResults
public function getPageResults()
{
Console::writeLine('fetching');
$this->fetch();
file_put_contents(Yii::app()->basePath . '/reports/pagehtml.html', $this->pageHtml);
CVarDumper::dump($this->response, 10, false);
die('Debug Point');
}
示例3: main
/**
* Main
*
* @param string[] args
* @return int
*/
public static function main(array $args)
{
Console::writeLinef('XP %s { PHP %s & ZE %s } @ %s', xp::version(), phpversion(), zend_version(), php_uname());
Console::writeLine('Copyright (c) 2001-2013 the XP group');
foreach (ClassLoader::getLoaders() as $delegate) {
Console::writeLine($delegate->toString());
}
return 1;
}
示例4: classLoaderInformation
/**
* Display some information
*
* Annotate this method w/ @test to retrieve debug information.
*/
public function classLoaderInformation()
{
with($p = Package::forName('net.xp_framework.unittest.reflection.classes'));
Console::writeLine('Object : ', XPClass::forName('lang.Object')->getClassLoader());
Console::writeLine('This : ', $this->getClass()->getClassLoader());
Console::writeLine('ClassOne : ', $p->loadClass('ClassOne')->getClassLoader());
Console::writeLine('ClassTwo : ', $p->loadClass('ClassTwo')->getClassLoader());
Console::writeLine('ClassThree : ', $p->loadClass('ClassThree')->getClassLoader());
Console::writeLine('ClassFour : ', $p->loadClass('ClassFour')->getClassLoader());
Console::writeLine('ClassFive : ', $p->loadClass('ClassFive')->getClassLoader());
}
示例5: visit
public function visit($Object)
{
if (is('org.dia.DiaObject', $Object)) {
Console::writeLine("DiaObject: " . $Object->getName());
}
if (is('org.dia.DiaComposite', $Object)) {
$name = $Object->getName();
if (isset($name)) {
Console::writeLine("DiaComposite: {$name}");
}
}
}
示例6: main
/**
* Entry point method. Gets passed the following arguments from "xpws -i":
* <ol>
* <li>The web root - defaults to $CWD</li>
* <li>The configuration directory - defaults to "etc"</li>
* <li>The server profile - default to "dev"</li>
* <li>The server address - default to "localhost:8080"</li>
* </ol>
*
* @param string[] args
*/
public static function main(array $args)
{
$webroot = isset($args[0]) ? realpath($args[0]) : getcwd();
$configd = isset($args[1]) ? $args[1] : 'etc';
$profile = isset($args[2]) ? $args[2] : 'dev';
$address = isset($args[3]) ? $args[3] : 'localhost:8080';
Console::writeLine('xpws-', $profile, ' @ ', $address, ', ', $webroot, ' {');
// Dump configured applications
$conf = new xp·scriptlet·WebConfiguration(new Properties($configd . DIRECTORY_SEPARATOR . 'web.ini'));
foreach ($conf->mappedApplications($profile) as $url => $app) {
Console::writeLine(' Route<', $url, '*> => ', xp::stringOf($app, ' '));
}
Console::writeLine('}');
}
示例7: marshal
/**
*
* @param array classnames List of fully qualified class names
* @param int recurse default 0
* @param bool depend default FALSE
* @return &org.dia.DiaDiagram
*/
public function marshal($classnames, $recurse = 0, $depend = FALSE)
{
// create new DiaDiagram
$Dia = new DiaDiagram();
// check classnames?
foreach ($classnames as $classname) {
try {
$Class = XPClass::forName($Classname);
} catch (Exception $e) {
Console::writeLine("CLASS NOT FOUND: {$classname}!");
}
}
return TestMarshaller::recurse($Dia, $classnames, $recurse, $depend);
}
示例8: main
/**
* Start server
*
* @param string[] args
*/
public static function main(array $args)
{
// Add shutdown message handler
EascMessageFactory::setHandler(61, newinstance('remote.server.message.EascMessage', array(), '{
public function getType() {
return 61;
}
public function handle($protocol, $data) {
Logger::getInstance()->getCategory()->debug("Shutting down");
$protocol->server->terminate= TRUE;
}
}')->getClass());
$s = new Server('127.0.0.1', 0);
try {
$protocol = new EascProtocol(newinstance('remote.server.deploy.scan.DeploymentScanner', array(), '{
private $changed= TRUE;
public function scanDeployments() {
$changed= $this->changed;
$this->changed= FALSE;
return $changed;
}
public function getDeployments() {
$res= "net/xp_framework/unittest/remote/deploy/beans.test.CalculatorBean.xar";
with ($d= new Deployment($res)); {
$d->setClassLoader(new ArchiveClassLoader(new Archive(ClassLoader::getDefault()->getResourceAsStream($res))));
$d->setImplementation("beans.test.CalculatorBeanImpl");
$d->setInterface("beans.test.Calculator");
$d->setDirectoryName("xp/test/Calculator");
return array($d);
}
}
}'));
$protocol->initialize();
$s->setProtocol($protocol);
$s->init();
Console::writeLinef('+ Service %s:%d', $s->socket->host, $s->socket->port);
$s->service();
Console::writeLine('+ Done');
} catch (Throwable $e) {
Console::writeLine('- ', $e->getMessage());
}
}
示例9: setup
/**
* Interactive database setup.
* WILL OUTPUT VIA CONSOLE!
*
* @param boolean $overwrite Overwrite existing config
* @return string
*/
public function setup($overwrite = false)
{
/**
* Output console usage
*/
if (!$this->console) {
throw new \RuntimeException('You can only use this action from a console!');
}
$this->console->writeLine("ZF2 Phinx Module - Interactive Setup", self::GREEN);
/**
* Check for existing config
*/
$zfConfig = $this->config['phinx-module']['zf2-config'];
$phinxConfig = $this->config['phinx-module']['phinx-config'];
if (!$overwrite && (file_exists($zfConfig) || file_exists($phinxConfig))) {
if (file_exists($zfConfig) && !file_exists($phinxConfig)) {
$this->sync();
$this->console->writeLine("ZF2 Config found but Phinx config missing => Config Synced.");
} else {
$this->console->writeLine("Existing config file(s) found, unable to continue!", self::LIGHT_RED);
$this->console->writeLine("Use the --overwrite flag to replace existing config.", self::LIGHT_RED);
}
return;
}
/**
* Ask questions
*/
$loop = true;
while ($loop) {
$this->console->writeLine("MySQL Database connection details:");
$host = Prompt\Line::prompt("Hostname? [localhost] ", true) ?: 'localhost';
$port = Prompt\Line::prompt("Port? [3306] ", true) ?: 3306;
$user = Prompt\Line::prompt("Username? ");
$pass = Prompt\Line::prompt("Password? ");
$dbname = Prompt\Line::prompt("Database name? ");
$loop = !Prompt\Confirm::prompt("Save these details? [y/n]");
}
/**
* Build config
*/
$config = new Config(array('db' => array('dsn' => "mysql:host={$host};dbname={$dbname}", 'username' => $user, 'password' => $pass, 'port' => $port)));
$writer = new PhpArray();
$writer->toFile($zfConfig, $config);
$this->console->writeLine();
$this->console->writeLine("ZF2 Config file written: {$zfConfig}");
/**
* Write Phinx config
*/
$migrations = $this->config['phinx-module']['migrations'];
$this->writePhinxConfig('mysql', $host, $user, $pass, $dbname, $port, $migrations);
$this->console->writeLine("Phinx Config file written: {$phinxConfig}");
}
示例10: extract
/**
* Extract a ".ar" file into a given target directory
*
* @param string base
* @param string ar
* @param io.Folder target
* @throws lang.IllegalStateException in case the target is not found
* @throws lang.FormatException in case the .ar-file is not parseable
*/
protected function extract($base, $ar, Folder $target)
{
// Open a HTTP connection
$url = new URL($base . $ar . '.ar');
$r = create(new HttpConnection($url))->get();
if (HttpConstants::STATUS_OK != $r->getStatusCode()) {
throw new IllegalStateException(sprintf('Unexpected response %d:%s for %s', $r->getStatusCode(), $r->getMessage(), $url->getURL()));
}
$in = new BufferedInputStream($r->getInputStream());
do {
// Seach for first section header, --[LENGTH]:[FILENAME]-- and parse it
do {
$line = $this->readLine($in);
if (!$in->available()) {
throw new FormatException('Cannot locate section header');
}
} while (2 !== sscanf($line, '--%d:%[^:]--', $length, $filename));
// Calculate target file
$file = new File($target, $filename);
$folder = new Folder($file->getPath());
$folder->exists() || $folder->create();
Console::writef(' >> [%-10s] %s (%.2f kB) [%s]%s', $ar, $filename, $length / 1024, str_repeat('.', self::PROGRESS_INDICATOR_WIDTH), str_repeat("", self::PROGRESS_INDICATOR_WIDTH + 1));
// Transfer length bytes into file
$c = 0;
$out = $file->getOutputStream();
$size = 0;
while ($size < $length) {
$chunk = $in->read(min(0x1000, $length - $size));
$size += strlen($chunk);
$out->write($chunk);
// Update progress
$d = ceil($size / $length * self::PROGRESS_INDICATOR_WIDTH);
if ($d == $c) {
continue;
}
Console::write(str_repeat('#', $d - $c));
$c = $d;
}
$out->close();
Console::writeLine();
} while ($in->available() > 0);
$in->close();
}
示例11: main
/**
* Main
*
* @param string[] args
*/
public static function main(array $args)
{
$way = array_shift($args);
// Read sourcecode from STDIN if no further argument is given
if (0 === sizeof($args)) {
$src = file_get_contents('php://stdin');
} else {
$src = $args[0];
}
$src = trim($src, ' ;') . ';';
// Extract uses() and load classes
if (0 === strncmp($src, 'uses', 4)) {
$p = strpos($src, ');');
$uses = substr($src, 5, $p - 5);
// "uses("
$src = substr($src, $p + 2);
// ");"
foreach (explode(',', $uses) as $class) {
uses(trim($class, '" '));
}
}
// Allow missing return
strstr($src, 'return ') || strstr($src, 'return;') || ($src = 'return ' . $src);
// Rewrite argc, argv
$argv = array(xp::nameOf(__CLASS__)) + $args;
$argc = sizeof($argv);
// Perform
$return = eval($src);
switch ($way) {
case '-w':
Console::writeLine($return);
break;
case '-d':
var_dump($return);
break;
}
}
示例12: perform
/**
* Perform this action
*
* @param string[] args
*/
public function perform(array $args)
{
$installation = new Installation();
$installation->setBase(new Folder(isset($args[0]) ? $args[0] : dirname(Runtime::getInstance()->bootstrapScript()) . '/..'));
$force = in_array('-f', $args);
with($version = $installation->getVersion());
Console::writeLine('===> Local version ', $version, ' @ ', $installation->getBase());
if (strstr($version, '-dev')) {
Console::writeLine('*** Cannot update development checkouts');
return 2;
}
// Query releases website for newer versions
$c = new HttpConnection(self::UPGRADE_URL);
$r = $c->get(new RequestData($version));
switch ($r->getStatusCode()) {
case HttpConstants::STATUS_OK:
case HttpConstants::STATUS_NOT_EXTENDED:
Console::writeLine('*** ', $this->readLine($r->getInputStream()));
return 2;
case HttpConstants::STATUS_SEE_OTHER:
$upgrade = $r->getHeader('X-Upgrade-To');
$base = $r->getHeader('Location');
Console::writeLine('---> Upgrading to ', $upgrade, ' (', $base, ')');
$target = new Folder($installation->getBase(), $upgrade);
$target->exists() || $target->create();
// Verify dependencies
$this->extract($base, 'depend', $target);
with($p = new Properties($target->getURI() . 'depend.ini'));
$verify = 1;
$rtversion = phpversion();
$extensions = array_flip(array_map('strtolower', get_loaded_extensions()));
foreach ($p->readSection('php') as $op => $compare) {
if (!version_compare(phpversion(), $compare, $op)) {
$verify &= $this->error('PHP version ' . $op . ' ' . $compare . ' required, have ' . $rtversion);
}
}
foreach ($p->readSection('ext.required') as $ext => $usage) {
if (!isset($extensions[$ext])) {
$verify &= $this->error('PHP Extension ' . $ext . ' required for ' . $usage);
}
}
foreach ($p->readSection('ext.conflict') as $ext => $usage) {
if (isset($extensions[$ext])) {
$verify &= $this->error('PHP Extension ' . $ext . ' conflicts (' . $usage . ')');
}
}
foreach ($p->readSection('ext.optional') as $ext => $usage) {
if (!isset($extensions[$ext])) {
$verify &= $this->error('PHP Extension ' . $ext . ' not found, needed for ' . $usage . ' (ignoring)');
}
}
foreach ($p->readSection('ini') as $setting => $match) {
$value = ini_get($setting);
if (!preg_match($match, $value)) {
$verify &= $this->error('PHP .ini setting ' . $setting . ' needs to match ' . $match . ' (but is ' . $value . ')');
}
}
// Remove depend.ini, finally check if we should continue
create(new File($p->getFilename()))->unlink();
if (!$verify) {
if (!$force) {
return 3;
}
Console::writeLine('!!! Ignoring errors because -f was passed');
}
// Download base, tools, libraries and meta information
$this->extract($base, 'base', $target);
$this->extract($base, 'tools', $target);
$this->extract($base, 'lib', $target);
$this->extract($base, 'meta-inf', $target);
// Verify it works by running the XP Framework core unittests
$tests = array('net.xp_framework.unittest.core.**');
Console::writeLine('---> Running tests with [USE_XP=', $upgrade, ']:');
$rt = Runtime::getInstance();
set_include_path(implode(PATH_SEPARATOR, array(rtrim($target->getURI(), DIRECTORY_SEPARATOR), '', $target->getURI() . 'lib' . DIRECTORY_SEPARATOR . 'xp-net.xp_framework-' . $upgrade . '.xar')));
with($p = $rt->newInstance($rt->startupOptions(), 'class', 'xp.unittest.Runner', $tests));
$p->in->close();
while (!$p->out->eof()) {
Console::writeLine($p->out->readLine());
}
while (!$p->err->eof()) {
Console::writeLine($p->err->readLine());
}
$exit = $p->close();
// Nonzero exit means failure
if (0 !== $exit) {
Console::writeLine('*** Test run failed, please consult above error messsages');
Console::writeLine($p->getCommandLine());
return 2;
}
Console::writeLine('===> Done, installed @ ', $target);
return 0;
default:
throw new IllegalStateException('Unexpected response ' . xp::stringOf($r));
}
//.........这里部分代码省略.........
示例13: main
/**
* Main method
*
* @param string[] args
*/
public static function main($args)
{
$sorted = ArrayList::newInstance($args)->sorted();
Console::writeLine('create(new ArrayList(array(', implode(', ', $args), ')))->sorted()= ', $sorted);
}
示例14: main
/**
* Main runner method
*
* @param string[] args
*/
public static function main(array $args)
{
if (!$args) {
self::usage();
}
// Parse arguments
$output = '-';
for ($i = 0, $s = sizeof($args); $i < $s; $i++) {
if ('-O' == $args[$i]) {
$output = $args[++$i];
} else {
if ('-?' == $args[$i] || '--help' == $args[$i]) {
self::usage();
} else {
$package = $args[$i];
break;
}
}
}
// Load generator class
try {
$class = Package::forName('xp.codegen')->getPackage($package)->loadClass('Generator');
} catch (ElementNotFoundException $e) {
Console::$err->writeLine('*** No generator named "' . $package . '"');
exit(2);
}
$params = new ParamString(array_slice($args, $i + 1));
if ($params->exists('help', '?')) {
Console::$err->writeLine(self::textOf($class->getComment()));
exit(1);
}
// Instantiate generator
$generator = $class->newInstance($params);
$generator->storage = new FileSystemStorage(System::tempDir());
// Output
if ('-' === $output) {
$generator->output = new ConsoleOutput(Console::$err);
} else {
if (strstr($output, '.xar')) {
$generator->output = new ArchiveOutput($output);
} else {
$generator->output = new FileSystemOutput($output);
}
}
$generator->output->addObserver(newinstance('util.Observer', array(), '{
public function update($obs, $arg= NULL) { Console::writeLine(" >> ", $arg); }
}'));
Console::writeLine('===> Starting ', $generator);
// Compile target chain
$empty = new ArrayList();
$targets = create('new util.collections.HashTable<lang.reflect.Method, util.collections.HashTable<string, lang.Generic>>()');
foreach ($class->getMethods() as $method) {
if (!$method->hasAnnotation('target')) {
continue;
}
$target = create('new util.collections.HashTable<string, lang.Generic>()');
// Fetch dependencies
if ($method->hasAnnotation('target', 'depends')) {
$depends = create('new util.collections.Vector<lang.reflect.Method>()');
foreach ((array) $method->getAnnotation('target', 'depends') as $dependency) {
$depends[] = $class->getMethod($dependency);
}
$target['depends'] = $depends;
}
// Fetch input
if ($method->hasAnnotation('target', 'input')) {
$arguments = create('new util.collections.Vector<lang.reflect.Method>()');
foreach ((array) $method->getAnnotation('target', 'input') as $input) {
$arguments[] = $class->getMethod($input);
}
$target['arguments'] = $arguments;
}
$targets->put($method, $target);
}
// Invoke
try {
foreach ($targets->keys() as $method) {
self::invoke($generator, $method, $targets);
}
} catch (TargetInvocationException $e) {
Console::$err->writeLine('*** ', $e->getCause());
exit(3);
}
$generator->output->commit();
Console::writeLine('===> Done');
}
示例15: main
/**
* Main
*
* @param string[] args
*/
public static function main(array $args)
{
if (sizeof($args) < 1 || '' == $args[0]) {
Console::$err->writeLine('*** No class or package name given');
return 2;
}
// Check whether a file, class or a package directory or name is given
$cl = ClassLoader::getDefault();
if (strstr($args[0], xp::CLASS_FILE_EXT)) {
$class = self::findClassBy(new File($args[0]));
} else {
if ($cl->providesClass($args[0])) {
$class = XPClass::forName($args[0], $cl);
} else {
if (strcspn($args[0], '\\/') < strlen($args[0])) {
$package = self::findPackageBy(new Folder($args[0]));
} else {
$package = $args[0];
}
$provided = FALSE;
foreach (ClassLoader::getLoaders() as $loader) {
if (!$loader->providesPackage($package)) {
continue;
}
Console::writeLine('@', $loader);
$provided = TRUE;
}
if ($provided) {
self::printPackage(Package::forName($package));
return 0;
}
// Not found
Console::$err->writeLine('*** Failed to locate either a class or a package named "', $args[0], '", tried all of {');
foreach (ClassLoader::getLoaders() as $loader) {
Console::$err->writeLine(' ', $loader);
}
Console::$err->writeLine('}');
return 1;
}
}
Console::writeLine('@', $class->getClassLoader());
if ($class->isInterface()) {
self::printInterface($class);
} else {
if ($class->isEnum()) {
self::printEnum($class);
} else {
self::printClass($class);
}
}
return 0;
}