本文整理汇总了PHP中Ftp::sslConnect方法的典型用法代码示例。如果您正苦于以下问题:PHP Ftp::sslConnect方法的具体用法?PHP Ftp::sslConnect怎么用?PHP Ftp::sslConnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ftp
的用法示例。
在下文中一共展示了Ftp::sslConnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Runs the FTP deploy task.
*
* @return Result The result of the task.
*/
public function run()
{
$ftp = new \Ftp();
// connect to the server
try {
if ($this->useSSL) {
$ftp->sslConnect($this->host);
} else {
$ftp->connect($this->host);
}
$ftp->login($this->user, $this->password);
// create the target directory if it does not exist
$ftp->chdir('/');
if (!$ftp->fileExists($this->targetDirectory)) {
$this->printTaskInfo('Creating directory: ' . $this->targetDirectory);
$ftp->mkDirRecursive($this->targetDirectory);
}
// get files from git if enabled
if ($this->gitDiff) {
$this->files($this->getGitDiff($ftp));
}
// scan and index files in finder
$this->printTaskInfo('Scanning files to upload...');
// add discrete files
$this->finder->append(new \ArrayIterator($this->files));
// directories first
$this->finder->sortByType();
// display summary before deploying
$this->printTaskInfo(sprintf('Deploying %d files to "%s://%s@%s%s"...', $this->finder->count(), $this->useSSL ? 'ftps' : 'ftp', $this->user, $this->host, $this->targetDirectory));
// upload each file, starting with directories
foreach ($this->finder as $file) {
$this->upload($ftp, $file);
}
// close the connection
$ftp->close();
} catch (\FtpException $e) {
return Result::error($this, 'Error: ' . $e->getMessage());
}
// success!
return Result::success($this, 'All files deployed.');
}