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


PHP Server::writeFile方法代码示例

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


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

示例1: uploadPaths

 /**
  * Uploades files and creates directories.
  * @param  string[]  relative paths, starts with /
  * @return void
  */
 private function uploadPaths(array $paths)
 {
     $prevDir = NULL;
     foreach ($paths as $num => $path) {
         $remotePath = $this->remoteDir . $path;
         $isDir = substr($remotePath, -1) === '/';
         $remoteDir = $isDir ? substr($remotePath, 0, -1) : str_replace('\\', '/', dirname($remotePath));
         if ($remoteDir !== $prevDir) {
             $prevDir = $remoteDir;
             $this->server->createDir($remoteDir);
         }
         if ($isDir) {
             $this->writeProgress($num + 1, count($paths), $path, NULL, 'green');
             continue;
         }
         $localFile = $this->preprocess($path);
         if ($localFile !== $this->localDir . $path) {
             $path .= ' (filters applied)';
         }
         $this->server->writeFile($localFile, $remotePath . self::TEMPORARY_SUFFIX, function ($percent) use($num, $paths, $path) {
             $this->writeProgress($num + 1, count($paths), $path, $percent, 'green');
         });
         $this->writeProgress($num + 1, count($paths), $path, NULL, 'green');
     }
 }
开发者ID:dg,项目名称:ftp-deployment,代码行数:30,代码来源:Deployer.php

示例2: uploadFiles

 /**
  * Uploades files.
  * @return void
  */
 private function uploadFiles(array $files)
 {
     $root = $this->server->getDir();
     $prevDir = NULL;
     $toRename = [];
     foreach ($files as $num => $file) {
         $remoteFile = $root . $file;
         $isDir = substr($remoteFile, -1) === '/';
         $remoteDir = $isDir ? substr($remoteFile, 0, -1) : str_replace('\\', '/', dirname($remoteFile));
         if ($remoteDir !== $prevDir) {
             $prevDir = $remoteDir;
             $this->server->createDir($remoteDir);
         }
         if ($isDir) {
             $this->writeProgress($num + 1, count($files), $file, NULL, 'green');
             continue;
         }
         $localFile = $this->preprocess($orig = $this->local . $file);
         if (realpath($orig) !== $localFile) {
             $file .= ' (filters applied)';
         }
         $toRename[] = $remoteFile;
         $this->server->writeFile($localFile, $remoteFile . self::TEMPORARY_SUFFIX, function ($percent) use($num, $files, $file) {
             $this->writeProgress($num + 1, count($files), $file, $percent, 'green');
         });
         $this->writeProgress($num + 1, count($files), $file, NULL, 'green');
     }
     $this->logger->log("\nRenaming:");
     foreach ($toRename as $num => $file) {
         $this->writeProgress($num + 1, count($toRename), "Renaming {$file}", NULL, 'olive');
         $this->server->renameFile($file . self::TEMPORARY_SUFFIX, $file);
     }
 }
开发者ID:hranicka,项目名称:dg-ftp-deployment,代码行数:37,代码来源:Deployer.php


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