本文整理汇总了PHP中Webmozart\PathUtil\Path::normalize方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::normalize方法的具体用法?PHP Path::normalize怎么用?PHP Path::normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\PathUtil\Path
的用法示例。
在下文中一共展示了Path::normalize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rebuild
/**
* Rebuild the puli dependencies for symfony container.
*/
protected function rebuild(InputInterface $input, OutputInterface $output)
{
$puli = new Puli(Path::join([getcwd(), NANBANDO_DIR]));
$puli->start();
/** @var EmbeddedComposerInterface $embeddedComposer */
$embeddedComposer = $this->getApplication()->getEmbeddedComposer();
$packageManager = $puli->getPackageManager();
$io = new ConsoleIO($input, $output, $this->getApplication()->getHelperSet());
$composer = $embeddedComposer->createComposer($io);
$installationManager = $composer->getInstallationManager();
$rootPackage = $composer->getPackage();
$repository = $composer->getRepositoryManager()->getLocalRepository();
$packages = [];
foreach ($repository->getPackages() as $package) {
$packages[$package->getName()] = $package;
}
foreach ($rootPackage->getRequires() as $require) {
if (!array_key_exists($require->getTarget(), $packages)) {
continue;
}
$packageManager->installPackage(Path::normalize($installationManager->getInstallPath($packages[$require->getTarget()])), $require->getTarget(), 'nanbando');
}
$filesystem = new Filesystem();
$filesystem->remove(Path::join([getcwd(), NANBANDO_DIR, '.puli']));
$discoveryManager = $puli->getDiscoveryManager();
if (!$discoveryManager->hasRootTypeDescriptor('nanbando/bundle')) {
$discoveryManager->addRootTypeDescriptor(new BindingTypeDescriptor(new BindingType('nanbando/bundle')), 0);
}
$discoveryManager->clearDiscovery();
$discoveryManager->buildDiscovery();
$filesystem = new Filesystem();
$filesystem->remove(Path::join([getcwd(), NANBANDO_DIR, 'app', 'cache']));
}
示例2: makeTempDir
/**
* Creates a temporary directory.
*
* @param string $namespace The directory path in the system's temporary
* directory.
* @param string $className The name of the test class.
*
* @return string The path to the created directory.
*/
public static function makeTempDir($namespace, $className)
{
if (false !== ($pos = strrpos($className, '\\'))) {
$shortClass = substr($className, $pos + 1);
} else {
$shortClass = $className;
}
// Usage of realpath() is important if the temporary directory is a
// symlink to another directory (e.g. /var => /private/var on some Macs)
// We want to know the real path to avoid comparison failures with
// code that uses real paths only
$systemTempDir = Path::normalize(realpath(sys_get_temp_dir()));
$basePath = $systemTempDir . '/' . $namespace . '/' . $shortClass;
while (false === @mkdir($tempDir = $basePath . rand(10000, 99999), 0777, true)) {
// Run until we are able to create a directory
}
return $tempDir;
}
示例3: installNewPackages
/**
* @param PackageInterface[] $composerPackages
* @param bool[] $prodPackageNames
* @param PuliPackage[] $puliPackages
* @param IOInterface $io
* @param Composer $composer
*/
private function installNewPackages(array $composerPackages, array $prodPackageNames, array &$puliPackages, IOInterface $io, Composer $composer)
{
$installationManager = $composer->getInstallationManager();
foreach ($composerPackages as $packageName => $package) {
if ($package instanceof AliasPackage) {
$package = $package->getAliasOf();
}
// We need to normalize the system-dependent paths returned by Composer
$installPath = Path::normalize($installationManager->getInstallPath($package));
$env = isset($prodPackageNames[$packageName]) ? PuliPackage::ENV_PROD : PuliPackage::ENV_DEV;
// Skip meta packages
if ('' === $installPath) {
continue;
}
if (isset($puliPackages[$packageName])) {
$puliPackage = $puliPackages[$packageName];
// Only proceed if the install path or environment has changed
if ($installPath === $puliPackage->getInstallPath() && $env === $puliPackage->getEnvironment()) {
continue;
}
// Only remove packages installed by Composer
if (self::INSTALLER_NAME === $puliPackage->getInstallerName()) {
$io->write(sprintf('Reinstalling <info>%s</info> (<comment>%s</comment>) in <comment>%s</comment>', $packageName, Path::makeRelative($installPath, $this->rootDir), $env));
try {
$this->removePackage($packageName);
} catch (PuliRunnerException $e) {
$this->printPackageWarning($io, 'Could not remove package "%s" (at ./%s)', $packageName, $installPath, $e);
continue;
}
}
} else {
$io->write(sprintf('Installing <info>%s</info> (<comment>%s</comment>) in <comment>%s</comment>', $packageName, Path::makeRelative($installPath, $this->rootDir), $env));
}
try {
$this->installPackage($installPath, $packageName, $env);
} catch (PuliRunnerException $e) {
$this->printPackageWarning($io, 'Could not install package "%s" (at ./%s)', $packageName, $installPath, $e);
continue;
}
$puliPackages[$packageName] = new PuliPackage($packageName, self::INSTALLER_NAME, $installPath, PuliPackage::STATE_ENABLED, $env);
}
}
示例4: testNormalizeFailsIfNoString
/**
* @expectedException \InvalidArgumentException
*/
public function testNormalizeFailsIfNoString()
{
Path::normalize(true);
}