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


PHP Filesystem::dirname方法代码示例

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


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

示例1: edit

 /**
  * Edit a file.
  * @param  string $path    Path to the file.
  * @param  string $search  What to replace.
  * @param  string $replace Text to replace with.
  * @return $this|Exception
  */
 public function edit($path)
 {
     $this->path = realpath(base_path($this->files->dirname($path)));
     $this->class = $this->files->name($path);
     $this->setFile($path);
     return $this;
 }
开发者ID:jeroen-g,项目名称:laravel-builder,代码行数:14,代码来源:Builder.php

示例2: fire

 public function fire()
 {
     $environment = $this->config->get('app.env');
     $gitSnifferEnv = $this->config->get('git-sniffer.env');
     if ($environment !== $gitSnifferEnv) {
         return;
     }
     $hooksDir = base_path('.git/hooks');
     if (!$this->files->isDirectory($hooksDir)) {
         $this->files->makeDirectory($hooksDir, 0755);
     }
     $preCommitHook = $hooksDir . '/pre-commit';
     $preCommitResource = $this->files->dirname(__DIR__) . '/resources/pre-commit';
     if ($this->files->exists($preCommitResource)) {
         $this->files->copy($preCommitResource, $preCommitHook);
     }
 }
开发者ID:avirdz,项目名称:laravel-git-sniffer,代码行数:17,代码来源:CopyHookCommand.php

示例3: dirname

 /**
  * Extract the parent directory from a file path.
  *
  * @param string $path
  * @return string 
  * @static 
  */
 public static function dirname($path)
 {
     return \Illuminate\Filesystem\Filesystem::dirname($path);
 }
开发者ID:whplay,项目名称:ohmate-shop,代码行数:11,代码来源:_ide_helper.php

示例4: fire

 /**
  * Handle the command
  */
 public function fire()
 {
     $environment = $this->config->get('app.env');
     $gitSnifferEnv = $this->config->get('git-sniffer.env');
     if ($environment !== $gitSnifferEnv) {
         return;
     }
     $phpcsBin = $this->config->get('git-sniffer.phpcs_bin');
     $eslintBin = $this->config->get('git-sniffer.eslint_bin');
     $eslintConfig = $this->config->get('git-sniffer.eslint_config');
     $eslintIgnorePath = $this->config->get('git-sniffer.eslint_ignore_path');
     if (!empty($phpcsBin)) {
         if (!$this->files->exists($phpcsBin)) {
             $this->error('PHP CodeSniffer bin not found');
             exit(1);
         }
     }
     if (!empty($eslintBin)) {
         if (!$this->files->exists($eslintBin)) {
             $this->error('ESLint bin not found');
             exit(1);
         } elseif (!$this->files->exists($eslintConfig)) {
             $this->error('ESLint config file not found');
             exit(1);
         }
         if (!empty($eslintIgnorePath)) {
             if (!$this->files->exists($eslintIgnorePath)) {
                 $this->error('ESLint ignore file not found');
                 exit(1);
             }
         }
     }
     if (empty($phpcsBin) && empty($eslintBin)) {
         $this->error('Eslint bin and Phpcs bin are not configured');
         exit(1);
     }
     $revision = trim(shell_exec('git rev-parse --verify HEAD'));
     $against = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
     if (!empty($revision)) {
         $against = 'HEAD';
     }
     //this is the magic:
     //retrieve all files in staging area that are added, modified or renamed
     //but no deletions etc
     $files = trim(shell_exec("git diff-index --name-only --cached --diff-filter=ACMR {$against} --"));
     if (empty($files)) {
         exit(0);
     }
     $tempStaging = $this->config->get('git-sniffer.temp');
     //create temporary copy of staging area
     if ($this->files->exists($tempStaging)) {
         $this->files->deleteDirectory($tempStaging);
     }
     $fileList = explode("\n", $files);
     $validPhpExtensions = $this->config->get('git-sniffer.phpcs_extensions');
     $validEslintExtensions = $this->config->get('git-sniffer.eslint_extensions');
     $validFiles = [];
     foreach ($fileList as $l) {
         if (!empty($phpcsBin)) {
             if (in_array($this->files->extension($l), $validPhpExtensions)) {
                 $validFiles[] = $l;
             }
         }
         if (!empty($eslintBin)) {
             if (in_array($this->files->extension($l), $validEslintExtensions)) {
                 $validFiles[] = $l;
             }
         }
     }
     //Copy contents of staged version of files to temporary staging area
     //because we only want the staged version that will be commited and not
     //the version in the working directory
     if (empty($validFiles)) {
         exit(0);
     }
     $this->files->makeDirectory($tempStaging);
     $phpStaged = [];
     $eslintStaged = [];
     foreach ($validFiles as $f) {
         $id = shell_exec("git diff-index --cached {$against} \"{$f}\" | cut -d \" \" -f4");
         if (!$this->files->exists($tempStaging . '/' . $this->files->dirname($f))) {
             $this->files->makeDirectory($tempStaging . '/' . $this->files->dirname($f), 0755, true);
         }
         $output = shell_exec("git cat-file blob {$id}");
         $this->files->put($tempStaging . '/' . $f, $output);
         if (!empty($phpcsBin)) {
             if (in_array($this->files->extension($f), $validPhpExtensions)) {
                 $phpStaged[] = '"' . $tempStaging . '/' . $f . '"';
             }
         }
         if (!empty($eslintBin)) {
             if (in_array($this->files->extension($f), $validEslintExtensions)) {
                 $eslintStaged[] = '"' . $tempStaging . '/' . $f . '"';
             }
         }
     }
     $eslintOutput = null;
//.........这里部分代码省略.........
开发者ID:avirdz,项目名称:laravel-git-sniffer,代码行数:101,代码来源:CodeSnifferCommand.php


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