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


PHP Path::normalize方法代码示例

本文整理汇总了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']));
 }
开发者ID:nanbando,项目名称:core,代码行数:36,代码来源:ReconfigureCommand.php

示例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;
 }
开发者ID:webmozart,项目名称:glob,代码行数:27,代码来源:TestUtil.php

示例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);
     }
 }
开发者ID:issei-m,项目名称:composer-plugin,代码行数:49,代码来源:PuliPlugin.php

示例4: testNormalizeFailsIfNoString

 /**
  * @expectedException \InvalidArgumentException
  */
 public function testNormalizeFailsIfNoString()
 {
     Path::normalize(true);
 }
开发者ID:webmozart,项目名称:path-util,代码行数:7,代码来源:PathTest.php


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