本文整理汇总了PHP中Phing类的典型用法代码示例。如果您正苦于以下问题:PHP Phing类的具体用法?PHP Phing怎么用?PHP Phing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Phing类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: call_phing
public static function call_phing($task, $target, $build_file = '', $options = array())
{
$args = array();
foreach ($options as $key => $value) {
$args[] = "-D{$key}={$value}";
}
if ($build_file) {
$args[] = '-f';
$args[] = realpath($build_file);
}
if (!$task->is_verbose()) {
$args[] = '-q';
}
if (is_array($target)) {
$args = array_merge($args, $target);
} else {
$args[] = $target;
}
if (DIRECTORY_SEPARATOR != '\\' && (function_exists('posix_isatty') && @posix_isatty(STDOUT))) {
$args[] = '-logger';
$args[] = 'phing.listener.AnsiColorLogger';
}
Phing::startup();
Phing::setProperty('phing.home', getenv('PHING_HOME'));
$m = new pakePhing();
$m->execute($args);
$m->runBuild();
}
示例2: setUp
public function setUp()
{
Phing::startup();
$this->project = $this->getMockBuilder('Project')->setMethods(array('getBasedir'))->getMock();
$this->task = new GuessExtensionKeyTask();
$this->task->setProject($this->project);
}
示例3: testGetFileSystemReturnsCorrect
/**
* @dataProvider fileSystemMappingsDataProvider
*/
public function testGetFileSystemReturnsCorrect($expectedFileSystemClass, $fsTypeKey)
{
$this->_resetFileSystem();
Phing::setProperty('host.fstype', $fsTypeKey);
$system = FileSystem::getFileSystem();
$this->assertInstanceOf($expectedFileSystemClass, $system);
}
示例4: targetFinished
function targetFinished(BuildEvent $event)
{
$msg .= PHP_EOL . "Target time: " . self::formatTime(Phing::currentTimeMillis() - $this->targetStartTime) . PHP_EOL;
$event->setMessage($msg, Project::MSG_INFO);
$this->messageLogged($event);
$this->targetName = null;
}
示例5: call_phing
public static function call_phing($task, $target, $build_file = '', $options = array())
{
$args = array();
foreach ($options as $key => $value) {
$args[] = "-D{$key}={$value}";
}
if ($build_file) {
$args[] = '-f';
$args[] = realpath($build_file);
}
if (!$task->is_verbose()) {
$args[] = '-q';
}
if (is_array($target)) {
$args = array_merge($args, $target);
} else {
$args[] = $target;
}
Phing::startup();
Phing::setProperty('phing.home', getenv('PHING_HOME'));
ob_start(array('pakePhingTask', 'colorize'), 2);
$m = new pakePhing();
$m->execute($args);
$m->runBuild();
ob_end_clean();
}
示例6: setColors
/**
* Set the colors to use from a property file specified in the
* special phing property file "phing/listener/defaults.properties".
*/
private final function setColors()
{
$systemColorFile = new PhingFile(Phing::getResourcePath("phing/listener/defaults.properties"));
try {
$prop = new Properties();
$prop->load($systemColorFile);
$err = $prop->getProperty("HtmlColorLogger.ERROR_CLASS");
$warn = $prop->getProperty("HtmlColorLogger.WARNING_CLASS");
$info = $prop->getProperty("HtmlColorLogger.INFO_CLASS");
$verbose = $prop->getProperty("HtmlColorLogger.VERBOSE_CLASS");
$debug = $prop->getProperty("HtmlColorLogger.DEBUG_CLASS");
if ($err !== null) {
$this->errColor = self::PREFIX . $err . self::SUFFIX;
}
if ($warn !== null) {
$this->warnColor = self::PREFIX . $warn . self::SUFFIX;
}
if ($info !== null) {
$this->infoColor = self::PREFIX . $info . self::SUFFIX;
}
if ($verbose !== null) {
$this->verboseColor = self::PREFIX . $verbose . self::SUFFIX;
}
if ($debug !== null) {
$this->debugColor = self::PREFIX . $debug . self::SUFFIX;
}
} catch (IOException $ioe) {
//Ignore exception - we will use the defaults.
}
}
示例7: callFunction
/**
* Calls function and returns results.
* @return mixed
*/
protected function callFunction()
{
if ($this->class !== null) {
// import the classname & unqualify it, if necessary
$this->class = Phing::import($this->class);
$user_func = array($this->class, $this->function);
$h_func = $this->class . '::' . $this->function;
// human-readable (for log)
} else {
$user_func = $this->function;
$h_func = $user_func;
// human-readable (for log)
}
// put parameters into simple array
$params = array();
foreach ($this->params as $p) {
$params[] = $p->getValue();
}
$this->log("Calling PHP function: " . $h_func . "()");
foreach ($params as $p) {
$this->log(" param: " . $p, PROJECT_MSG_VERBOSE);
}
$return = call_user_func_array($user_func, $params);
return $return;
}
示例8: execute
public function execute($command)
{
// test if os match
$myos = Phing::getProperty("os.name");
$this->log("Myos = " . $myos, Project::MSG_VERBOSE);
if ($this->os !== null && strpos($this->os, $myos) === false) {
// this command will be executed only on the specified OS
$this->log("Not found in " . $this->os, Project::MSG_VERBOSE);
return 0;
}
if ($this->dir !== null) {
if ($this->dir->isDirectory()) {
$currdir = getcwd();
@chdir($this->dir->getPath());
} else {
throw new BuildException("Can't chdir to:" . $this->dir->__toString());
}
}
if ($this->escape == true) {
// FIXME - figure out whether this is correct behavior
$command = escapeshellcmd($command);
}
if ($this->error !== null) {
$command .= ' 2> ' . $this->error->getPath();
$this->log("Writing error output to: " . $this->error->getPath());
}
if ($this->output !== null) {
$command .= ' 1> ' . $this->output->getPath();
$this->log("Writing standard output to: " . $this->output->getPath());
} elseif ($this->spawn) {
$command .= ' 1>/dev/null';
$this->log("Sending ouptut to /dev/null");
}
// If neither output nor error are being written to file
// then we'll redirect error to stdout so that we can dump
// it to screen below.
if ($this->output === null && $this->error === null) {
$command .= ' 2>&1';
}
// we ignore the spawn boolean for windows
if ($this->spawn) {
$command .= ' &';
}
$this->log("Executing command: " . $command);
$return = null;
if ($this->passthru) {
passthru($command, $return);
} else {
$output = array();
exec($command, $output, $return);
}
if ($this->dir !== null) {
@chdir($currdir);
}
if ($return != 0 && $this->checkreturn) {
throw new BuildException("Task exited with code {$return}");
}
return $return;
}
示例9: setUp
protected function setUp()
{
if (version_compare(PHP_VERSION, '5.3.2') < 0) {
define('E_DEPRECATED', 8192);
}
chdir(dirname(__FILE__));
Phing::setProperty('phing.home', ZECLIB_TEST_VENDOR_DIR . '/phing');
Phing::startup();
}
示例10: setUp
public function setUp()
{
Phing::startup();
$this->base = $this->getMockBuilder('PhingFile')->setConstructorArgs(array(dirname(__FILE__) . '/../Fixtures/BaseLocalConfiguration.php'))->setMethods(NULL)->getMock();
$this->update = $this->getMockBuilder('PhingFile')->setConstructorArgs(array(dirname(__FILE__) . '/../Fixtures/UpdateLocalConfiguration.php'))->setMethods(NULL)->getMock();
$_tempTargetFile = tempnam('/tmp', 'tmp');
$tempTargetFile = $this->getMockBuilder('PhingFile')->setConstructorArgs(array($_tempTargetFile))->setMethods(NULL)->getMock();
$this->fileWriter = $this->getMockBuilder('FileWriter')->setConstructorArgs(array($tempTargetFile))->getMock();
$this->task = new MergeLocalConfigurationTask();
}
示例11: __construct
public function __construct()
{
// @todo These should have an auto-loader
require_once 'phing/Phing.php';
require_once 'phing/Project.php';
require_once 'phing/types/FileSet.php';
require_once 'phing/system/io/PhingFile.php';
require_once 'phing/system/util/Properties.php';
// Needs calling quite early (e.g. PhingFile won't work without it)
Phing::startup();
}
示例12: runBuild
/**
* @see Phing
*/
public function runBuild()
{
// workaround for included phing 2.3 which by default loads many tasks
// that are not needed and incompatible (eg phing.tasks.ext.FtpDeployTask)
// by placing current directory on the include path our defaults will be loaded
// see ticket #5054
$includePath = get_include_path();
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . $includePath);
parent::runBuild();
set_include_path($includePath);
}
示例13: setUp
public function setUp()
{
Phing::startup();
$this->project = $this->getMockBuilder('Project')->setMethods(NULL)->getMock(NULL);
$tempTargetFile = tempnam('/tmp', 'tmp');
$this->file = $this->getMockBuilder('PhingFile')->setConstructorArgs(array($tempTargetFile))->setMethods(NULL)->getMock();
$propertyTask = $this->getMockBuilder('PropertyTask')->setMethods(NULL)->getMock();
$propertyTask->setProject($this->project);
$propertyTask->setFile(dirname(__FILE__) . '/../Fixtures/LocalConfiguration.properties');
$propertyTask->setPrefix('LocalConfiguration.');
$propertyTask->main();
$this->task = new GenerateLocalConfigurationTask();
$this->task->setProject($this->project);
}
示例14: main
/**
* Does the work.
*
* @throws BuildException if someting goes wrong with the build
*/
public final function main()
{
if ($this->cvsRoot === null) {
throw new BuildException("cvsroot is required");
}
if ($this->password === null) {
throw new BuildException("password is required");
}
$this->log("cvsRoot: " . $this->cvsRoot, PROJECT_MSG_DEBUG);
$this->log("password: " . $this->password, PROJECT_MSG_DEBUG);
$this->log("passFile: " . $this->passFile->__toString(), PROJECT_MSG_DEBUG);
$reader = null;
$writer = null;
try {
$buf = "";
if ($this->passFile->exists()) {
$reader = new BufferedReader(new FileReader($this->passFile));
$line = null;
while (($line = $reader->readLine()) !== null) {
if (!StringHelper::startsWith($this->cvsRoot, $line)) {
$buf .= $line . Phing::getProperty("line.separator");
}
}
}
$pwdfile = $buf . $this->cvsRoot . " A" . $this->mangle($this->password);
$this->log("Writing -> " . $pwdfile, PROJECT_MSG_DEBUG);
$writer = new BufferedWriter(new FileWriter($this->passFile));
$writer->write($pwdfile);
$writer->newLine();
$writer->close();
if ($reader) {
$reader->close();
}
} catch (IOException $e) {
if ($reader) {
try {
$reader->close();
} catch (Exception $e) {
}
}
if ($writer) {
try {
$writer->close();
} catch (Exception $e) {
}
}
throw new BuildException($e);
}
}
示例15: evaluate
function evaluate()
{
$osName = strtolower(Phing::getProperty("os.name"));
if ($this->family !== null) {
if ($this->family === "windows") {
return StringHelper::startsWith("win", $osName);
} elseif ($this->family === "mac") {
return strpos($osName, "mac") !== false || strpos($osName, "darwin") !== false;
} elseif ($this->family === "unix") {
return StringHelper::endsWith("ix", $osName) || StringHelper::endsWith("ux", $osName) || StringHelper::endsWith("bsd", $osName) || StringHelper::startsWith("sunos", $osName) || StringHelper::startsWith("darwin", $osName);
}
throw new BuildException("Don't know how to detect os family '" . $this->family . "'");
}
return false;
}