本文整理汇总了PHP中CLI::writeln方法的典型用法代码示例。如果您正苦于以下问题:PHP CLI::writeln方法的具体用法?PHP CLI::writeln怎么用?PHP CLI::writeln使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLI
的用法示例。
在下文中一共展示了CLI::writeln方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
{$create}
');
}
public static function validate(\$data){
return Check::valid([
{$valids}
], \$data);
}
}
EOC;
$models[$table] = $model;
}
$force = CLI::input('force', false);
foreach ($models as $table => $model) {
$file = dirname(__DIR__) . "/models/{$model->name}.php";
if (!$force && file_exists($file)) {
CLI::writeln("<red>Already founded a model named <b>{$model->name}</b>, skipping...</red>");
} else {
CLI::writeln("<green>Compiling</green> model : <b>{$model->name}</b>");
file_put_contents($file, $model->code);
}
}
break;
default:
echo "Model utilities.", PHP_EOL;
echo "- Available actions: generate --force", PHP_EOL;
break;
}
});
示例2: function
<?php
/**
* Server utilities
*/
CLI::on('server :action', function ($action) {
switch ($action) {
case 'run':
$host = CLI::input("host", '0.0.0.0');
$port = CLI::input("port", 8888);
CLI::write("[<white>APP</white>] <purple>Starting</purple> webserver on <cyan>{$host}</cyan>:<green>{$port}</green>");
CLI::writeln("");
exec("(which open && open http://{$host}:{$port}/); php -S {$host}:{$port} -t " . dirname(__DIR__) . "/public");
break;
default:
echo "Server utilities.", PHP_EOL;
echo "- Available actions: run", PHP_EOL;
break;
}
});