本文整理汇总了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;
}
示例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);
}
}
示例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);
}
示例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;
//.........这里部分代码省略.........