本文整理汇总了PHP中FileSystem::normalizePath方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::normalizePath方法的具体用法?PHP FileSystem::normalizePath怎么用?PHP FileSystem::normalizePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::normalizePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: savePsr4s
public static function savePsr4s($vendorDir, $localPsr4Config, $io)
{
$filesystem = new FileSystem();
$psr4File = $filesystem->normalizePath(realpath($vendorDir . self::PSR4_FILE));
if ($localPsr4Config && $psr4File) {
$io->write('generating local autoload_psr4.php ....');
self::appendBeforeLastline($localPsr4Config, $psr4File);
$io->write('local autoload_psr4 generated.');
}
}
示例2: generateFakeAutoloadFile
/**
* Generates fake autoload file pointing to real autoload.php
*
* @param BasePackage packager
* @param string target file path
*/
protected function generateFakeAutoloadFile(BasePackage $package, $targetPath)
{
// Prepare paths
$packageInstallPath = $this->getInstallPath($package);
$targetDir = $this->fs->normalizePath($packageInstallPath . '/' . dirname($targetPath));
$targetBasename = basename($targetPath);
// Create short path to fake autoload file (for display purposes)
$displayFilePath = $this->fs->findShortestPath($this->getBasePath(), "{$targetDir}/{$targetBasename}");
// If target directory does not exist, skip
if (!is_dir($targetDir)) {
$this->io->write('Skiping generation of fake autoload file: ' . $displayFilePath);
return;
}
// Find relative path from directory of fake autoload file to real autoload.php
$relativePath = $this->fs->findShortestPath($targetDir, $this->getVendorDirPath(), TRUE);
$autoloadPath = var_export('/' . rtrim($relativePath, '/') . '/autoload.php', TRUE);
// Create fake autoload content
$content = <<<BOOTSTRAP_END
<?php
/**
* @warning This file is automatically generated by Composer.
* @see https://github.com/vbuilder/composer-plugin
*/
return include __DIR__ . {$autoloadPath};
BOOTSTRAP_END;
// Write
$this->io->write('Generating fake autoload in: ' . $displayFilePath);
file_put_contents($targetDir . '/' . $targetBasename, $content);
// Mark file as unchanged for Git
if (is_dir("{$packageInstallPath}/.git")) {
$exitCode = $this->process->execute('git --git-dir ' . escapeshellarg("{$packageInstallPath}/.git") . ' --work-tree ' . escapeshellarg($packageInstallPath) . ' update-index --assume-unchanged ' . escapeshellarg($targetPath));
if ($exitCode) {
throw new \RuntimeException('Failed to mark ' . $displayFilePath . ' as unchanged');
}
}
}