当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::getDir方法代码示例

本文整理汇总了PHP中Server::getDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::getDir方法的具体用法?PHP Server::getDir怎么用?PHP Server::getDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server::getDir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteFiles

 /**
  * Deletes files.
  * @return void
  */
 private function deleteFiles(array $files)
 {
     rsort($files);
     $root = $this->server->getDir();
     foreach ($files as $num => $file) {
         $remoteFile = $root . $file;
         $this->writeProgress($num + 1, count($files), "Deleting {$file}", NULL, 'maroon');
         try {
             if (substr($file, -1) === '/') {
                 // is directory?
                 $this->server->removeDir($remoteFile);
             } else {
                 $this->server->removeFile($remoteFile);
             }
         } catch (ServerException $e) {
             $this->logger->log("Unable to delete {$remoteFile}", 'red');
         }
     }
 }
开发者ID:hranicka,项目名称:dg-ftp-deployment,代码行数:23,代码来源:Deployer.php

示例2: deploy

 /**
  * Synchronize remote and local.
  * @return void
  */
 public function deploy()
 {
     $this->logger->log("Connecting to server");
     $this->server->connect();
     $this->remoteDir = $this->server->getDir();
     $runBefore = [NULL, NULL];
     foreach ($this->runBefore as $job) {
         $runBefore[is_string($job) && preg_match('#^local:#', $job)][] = $job;
     }
     if ($runBefore[1]) {
         $this->logger->log("\nLocal-jobs:");
         $this->runJobs($runBefore[1]);
         $this->logger->log('');
     }
     $remotePaths = $this->loadDeploymentFile();
     if (is_array($remotePaths)) {
         $this->logger->log("Loaded remote {$this->deploymentFile} file");
     } else {
         $this->logger->log("Remote {$this->deploymentFile} file not found");
         $remotePaths = [];
     }
     $this->logger->log("Scanning files in {$this->localDir}");
     $localPaths = $this->collectPaths();
     unset($localPaths["/{$this->deploymentFile}"], $remotePaths["/{$this->deploymentFile}"]);
     $toDelete = $this->allowDelete ? array_keys(array_diff_key($remotePaths, $localPaths)) : [];
     $toUpload = array_keys(array_diff_assoc($localPaths, $remotePaths));
     if ($localPaths !== $remotePaths) {
         // ignores allowDelete
         $deploymentFile = $this->writeDeploymentFile($localPaths);
         $toUpload[] = "/{$this->deploymentFile}";
         // must be last
     }
     if (!$toUpload && !$toDelete) {
         $this->logger->log('Already synchronized.', 'lime');
         return;
     } elseif ($this->testMode) {
         $this->logger->log("\nUploading:\n" . implode("\n", $toUpload), 'green', FALSE);
         $this->logger->log("\nDeleting:\n" . implode("\n", $toDelete), 'maroon', FALSE);
         if (isset($deploymentFile)) {
             unlink($deploymentFile);
         }
         return;
     }
     $this->logger->log("Creating remote file {$this->deploymentFile}.running");
     $runningFile = "{$this->remoteDir}/{$this->deploymentFile}.running";
     $this->server->createDir(str_replace('\\', '/', dirname($runningFile)));
     $this->server->writeFile(tempnam($this->tempDir, 'deploy'), $runningFile);
     if ($runBefore[0]) {
         $this->logger->log("\nBefore-jobs:");
         $this->runJobs($runBefore[0]);
     }
     if ($toUpload) {
         $this->logger->log("\nUploading:");
         $this->uploadPaths($toUpload);
         if ($this->runAfterUpload) {
             $this->logger->log("\nAfter-upload-jobs:");
             $this->runJobs($this->runAfterUpload);
         }
         $this->logger->log("\nRenaming:");
         $this->renamePaths($toUpload);
         unlink($deploymentFile);
     }
     if ($toDelete) {
         $this->logger->log("\nDeleting:");
         $this->deletePaths($toDelete);
     }
     foreach ((array) $this->toPurge as $path) {
         $this->logger->log("\nCleaning {$path}");
         $this->server->purge($this->remoteDir . '/' . $path, function ($path) {
             static $counter;
             $path = substr($path, strlen($this->remoteDir));
             $path = preg_match('#/(.{1,60})$#', $path, $m) ? $m[1] : substr(basename($path), 0, 60);
             $this->logger->progress(str_pad($path . ' ' . str_repeat('.', $counter++ % 30 + 60 - strlen($path)), 90));
         });
         $this->logger->progress(str_repeat(' ', 91));
     }
     if ($this->runAfter) {
         $this->logger->log("\nAfter-jobs:");
         $this->runJobs($this->runAfter);
     }
     $this->logger->log("\nDeleting remote file {$this->deploymentFile}.running");
     $this->server->removeFile($runningFile);
 }
开发者ID:dg,项目名称:ftp-deployment,代码行数:87,代码来源:Deployer.php


注:本文中的Server::getDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。