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


PHP Filesystem::symlink方法代码示例

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


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

示例1: publish

 /**
  * @param string $targetPath
  * @param string $installPath
  * @param array $map
  * @param bool $isSymlink
  * @param bool $isRelative
  *
  * @throws IOException
  * @throws \InvalidArgumentException
  *
  * @api
  *
  * @quality:method [B]
  */
 public function publish($targetPath, $installPath, array $map, $isSymlink, $isRelative)
 {
     $targetPath = rtrim($targetPath, '/');
     $installPath = rtrim($installPath, '/');
     $this->filesystem->mkdir($targetPath, 0777);
     foreach ($map as $from => $to) {
         $targetDir = realpath($targetPath) . '/' . $to;
         $sourceDir = realpath($installPath) . '/' . $from;
         $this->filesystem->remove($targetDir);
         if ($isSymlink) {
             $this->io->write(sprintf('Trying to install AdminLTE %s assets as symbolic links.', $from));
             $originDir = $sourceDir;
             if ($isRelative) {
                 $originDir = $this->filesystem->makePathRelative($sourceDir, realpath($targetPath));
             }
             try {
                 $this->filesystem->symlink($originDir, $targetDir);
                 $this->io->write(sprintf('The AdminLTE %s assets were installed using symbolic links.', $from));
             } catch (IOException $e) {
                 $this->hardCopy($sourceDir, $targetDir);
                 $this->io->write(sprintf('It looks like your system doesn\'t support symbolic links,
                     so the AdminLTE %s assets were installed by copying them.', $from));
             }
         } else {
             $this->io->write(sprintf('Installing AdminLTE %s assets as <comment>hard copies</comment>.', $from));
             $this->hardCopy($sourceDir, $targetDir);
         }
     }
 }
开发者ID:kamilsk,项目名称:common,代码行数:43,代码来源:Processor.php

示例2: symlinkPackageToVendor

 private function symlinkPackageToVendor($packagePath, $vendorPath)
 {
     $relative = $this->fileSystem->makePathRelative(realpath($packagePath), realpath($vendorPath . '/../'));
     $this->fileSystem->rename($vendorPath, $vendorPath . '_linked', true);
     $this->fileSystem->symlink($relative, $vendorPath);
     $this->fileSystem->remove($vendorPath . '_linked');
 }
开发者ID:mybuilder,项目名称:conductor,代码行数:7,代码来源:Conductor.php

示例3: deploy_build

 /**
  * Deploy build.
  *
  * @throws runtime_exception If deployment failed
  * @return $this
  */
 public function deploy_build()
 {
     if (!$this->fs->exists($this->build_dir)) {
         return $this;
     }
     $this->build_parents();
     $current_build = false;
     if ($this->fs->exists($this->production_link)) {
         if (is_link($this->production_link)) {
             $current_build = readlink($this->production_link);
         }
     }
     try {
         $new_build = $this->repo_dir . 'prod_' . time();
         $this->fs->rename($this->build_dir, $new_build);
         $this->fs->remove($this->production_link);
         $this->fs->symlink($new_build, $this->production_link);
     } catch (\Exception $e) {
         $this->fs->remove($this->production_link);
         if ($current_build) {
             $this->fs->symlink($current_build, $this->production_link);
         }
         throw new runtime_exception('PACKAGES_BUILD_DEPLOYMENT_FAILED');
     }
     if ($current_build) {
         $this->fs->remove($current_build);
     }
     return $this;
 }
开发者ID:Sajaki,项目名称:customisation-db,代码行数:35,代码来源:repository.php

示例4: publish

 /**
  * Copy all assets from a given path to the publish path.
  *
  * @param string $name
  * @param string $source
  * @throws \RuntimeException
  * @return bool
  */
 public function publish($name, $source)
 {
     $destination = $this->publishPath . "/packages/{$name}";
     try {
         $this->files->symlink($source, $destination);
     } catch (\Exception $e) {
         throw new \RuntimeException("Unable to publish assets.");
     }
     return true;
 }
开发者ID:djordje,项目名称:laravel-asset-symlinker,代码行数:18,代码来源:AssetSymlinker.php

示例5: symlink

 /**
  * {@inheritdoc}
  */
 public function symlink(string $origin, string $target, bool $copyOnWindows = false)
 {
     try {
         $this->filesystem->symlink($origin, $target, $copyOnWindows);
     } catch (IOException $exception) {
         throw new FilesystemException($exception->getMessage(), $exception->getPath(), $exception);
     } catch (Exception $exception) {
         throw new FilesystemException($exception->getMessage(), null, $exception);
     }
 }
开发者ID:novuso,项目名称:common-bundle,代码行数:13,代码来源:SymfonyFilesystem.php

示例6: symlink

 /**
  * Generates a symlink.
  *
  * The method will try to generate relative symlinks and fall back to generating
  * absolute symlinks if relative symlinks are not supported (see #208).
  *
  * @param string $source  The symlink name
  * @param string $target  The symlink target
  * @param string $rootDir The root directory
  */
 public static function symlink($source, $target, $rootDir)
 {
     static::validateSymlink($source, $target, $rootDir);
     $fs = new Filesystem();
     if ('\\' === DIRECTORY_SEPARATOR) {
         $fs->symlink($rootDir . '/' . $source, $rootDir . '/' . $target);
     } else {
         $fs->symlink(rtrim($fs->makePathRelative($source, dirname($target)), '/'), $rootDir . '/' . $target);
     }
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:20,代码来源:SymlinkUtil.php

示例7: link

 /**
  * @param $source
  * @param $target
  */
 protected function link($source, $target)
 {
     $targetDir = dirname($target);
     if (!$this->filesystem->exists($targetDir)) {
         $this->filesystem->mkdir($targetDir);
     }
     if ($this->filesystem->exists($target)) {
         $this->filesystem->remove($target);
     }
     $this->filesystem->symlink($source, $target);
 }
开发者ID:bcncommerce,项目名称:magebuild,代码行数:15,代码来源:SymlinkStrategy.php

示例8: cacheImage

 /**
  * Forces image caching and returns path to cached image.
  *
  * @param string  $basePath Deprecated parameter
  * @param string  $path
  * @param string  $filter
  * @param boolean $force
  * @param string  $saveAs
  *
  * @return string|null
  *
  * @throws RuntimeException
  */
 public function cacheImage($basePath, $path, $filter, $force = false, $saveAs = null)
 {
     $path = '/' . ltrim($path, '/');
     $saveAs = $saveAs ? '/' . ltrim($saveAs, '/') : $path;
     // if cache path cannot be determined, return 404
     if (!($cachedPath = $this->cachePathResolver->getCachedPath($saveAs, $filter))) {
         return null;
     }
     // if the file has already been cached, just return path
     if (!$force && is_file($cachedPath)) {
         return $cachedPath;
     }
     if (!($sourcePath = $this->cachePathResolver->getRealPath($path, $filter))) {
         return null;
     }
     $this->ensureDirectoryExists($cachedPath);
     try {
         $image = $this->imagine->open($sourcePath);
     } catch (RuntimeException $e) {
         try {
             // Make sure source path is an image
             new ImageFile($sourcePath, false);
             // Do not pollute the space (don't copy anything; symlink is just fine)
             $this->filesystem->symlink($sourcePath, $cachedPath);
         } catch (RuntimeException $e) {
             return null;
         } catch (IOException $e) {
             // In case we were not able to create symlink we should return source path.
             // This means we'll be back here, but at least we'll not be polluting space with useless copies.
             return $sourcePath;
         }
         return $cachedPath;
     }
     $options = ['quality' => $this->filterManager->getOption($filter, 'quality', $this->defaultQuality), 'format' => $this->filterManager->getOption($filter, 'format', null)];
     // Important! optipng filter returns an instance of ImageAssetWrapper.
     /** @var ImageInterface|ImageAssetWrapper $image */
     $image = $this->filterManager->getFilter($filter)->apply($image);
     /** @var resource $context */
     if ($context = $this->findStreamContext($cachedPath, $filter)) {
         $tmpPath = tempnam(sys_get_temp_dir(), 'avalanche-cache-manager-proxy-');
         $image->save($tmpPath, $options);
         copy($tmpPath, $cachedPath, $context);
         unlink($tmpPath);
     } else {
         $image->save($cachedPath, $options);
     }
     $this->ensureFilePermissions($cachedPath);
     return $cachedPath;
 }
开发者ID:jmcclell,项目名称:AvalancheImagineBundle,代码行数:62,代码来源:CacheManager.php

示例9: download

 /**
  * {@inheritdoc}
  */
 public function download(PackageInterface $package, $path)
 {
     $url = $package->getDistUrl();
     $realUrl = realpath($url);
     if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
         throw new \RuntimeException(sprintf('Source path "%s" is not found for package %s', $url, $package->getName()));
     }
     if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
         throw new \RuntimeException(sprintf('Package %s cannot install to "%s" inside its source at "%s"', $package->getName(), realpath($path), $realUrl));
     }
     $fileSystem = new Filesystem();
     $this->filesystem->removeDirectory($path);
     $this->io->writeError(sprintf('  - Installing <info>%s</info> (<comment>%s</comment>)', $package->getName(), $package->getFullPrettyVersion()));
     try {
         if (Platform::isWindows()) {
             // Implement symlinks as NTFS junctions on Windows
             $this->filesystem->junction($realUrl, $path);
             $this->io->writeError(sprintf('    Junctioned from %s', $url));
         } else {
             $shortestPath = $this->filesystem->findShortestPath($path, $realUrl);
             $fileSystem->symlink($shortestPath, $path);
             $this->io->writeError(sprintf('    Symlinked from %s', $url));
         }
     } catch (IOException $e) {
         $fileSystem->mirror($realUrl, $path);
         $this->io->writeError(sprintf('    Mirrored from %s', $url));
     }
     $this->io->writeError('');
 }
开发者ID:alcaeus,项目名称:composer,代码行数:32,代码来源:PathDownloader.php

示例10: dump

 /**
  * Dumps all translation files.
  *
  * @param string  $targetDir Target directory.
  * @param boolean $symlink   True if generate symlink
  *
  * @return null
  */
 public function dump($targetDir = 'web', $symlink = false, $directory = null)
 {
     $route = $this->router->getRouteCollection()->get('bazinga_exposetranslation_js');
     $directory = null === $directory ? $this->kernel->getRootDir() . '/../' : $directory;
     $requirements = $route->getRequirements();
     $formats = explode('|', $requirements['_format']);
     $routeDefaults = $route->getDefaults();
     $defaultFormat = $routeDefaults['_format'];
     $parts = array_filter(explode('/', $route->getPattern()));
     $this->filesystem->remove($directory . $targetDir . "/" . current($parts));
     foreach ($this->getTranslationMessages() as $locale => $domains) {
         foreach ($domains as $domain => $messageList) {
             foreach ($formats as $format) {
                 $content = $this->engine->render('BazingaExposeTranslationBundle::exposeTranslation.' . $format . '.twig', array('messages' => array($domain => $messageList), 'locale' => $locale, 'defaultDomains' => $domain));
                 $path[$format] = $directory . $targetDir . strtr($route->getPattern(), array('{domain_name}' => $domain, '{_locale}' => $locale, '{_format}' => $format));
                 $this->filesystem->mkdir(dirname($path[$format]), 0777);
                 if (file_exists($path[$format])) {
                     $this->filesystem->remove($path[$format]);
                 }
                 file_put_contents($path[$format], $content);
             }
             $targetFile = $directory . $targetDir;
             $targetFile .= strtr($route->getPattern(), array('{domain_name}' => $domain, '{_locale}' => $locale, '.{_format}' => ''));
             if (true === $symlink) {
                 $this->filesystem->symlink($path[$defaultFormat], $targetFile);
             } else {
                 $this->filesystem->copy($path[$defaultFormat], $targetFile);
             }
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:39,代码来源:TranslationDumper.php

示例11: installAssets

 /**
  * Installs the assets under the web root directory.
  *
  * @param CommandEvent $event A CommandEvent instance
  */
 public static function installAssets(CommandEvent $event)
 {
     $webDir = static::$options['pulsar-web-dir'];
     $fs = new Filesystem();
     // $fs->mirror(sprintf('%s/../Resources/public', __DIR__), sprintf('%s/pulsar', $webDir));
     $fs->symlink(sprintf('%s/../Resources/public', __DIR__), sprintf('%s/pulsar', $webDir), true);
 }
开发者ID:sfblaauw,项目名称:pulsar,代码行数:12,代码来源:ScriptHandler.php

示例12: prepareDrupalRoot

 /**
  * Links Drupal core, modules, themes and assets into Drupal root.
  *
  * @param Event $event
  */
 public static function prepareDrupalRoot(Event $event)
 {
     $options = self::getOptions($event);
     $composer = $event->getComposer();
     $filesystem = new Filesystem();
     $originDir = realpath($composer->getConfig()->get('vendor-dir') . '/drupal/drupal');
     $targetDir = realpath($options['drupal-root']);
     if (is_dir($originDir)) {
         if ($options['drupal-install']['relative']) {
             $originDir = rtrim($filesystem->makePathRelative($originDir, $targetDir), '/');
         }
         $directories = array('includes', 'misc', 'modules', 'themes');
         foreach ($directories as $directory) {
             $filesystem->remove($targetDir . '/' . $directory);
             if ($options['drupal-install']['symlink']) {
                 $event->getIO()->write(sprintf('Creating symlink for Drupal\'s \'%s\' directory', $directory));
                 $filesystem->symlink($originDir . '/' . $directory, $targetDir . '/' . $directory);
             } else {
                 $event->getIO()->write(sprintf('Copying Drupal\'s \'%s\' directory to web root', $directory));
                 $filesystem->mkdir($targetDir . '/' . $directory, 0777);
                 // We use a custom iterator to ignore VCS files
                 $filesystem->mirror($originDir . '/' . $directory, $targetDir . '/' . $directory, Finder::create()->ignoreDotFiles(false)->in($originDir));
             }
         }
     }
 }
开发者ID:bangpound,项目名称:drupal-bridge,代码行数:31,代码来源:ScriptHandler.php

示例13: installDrupal

 /**
  * Installs Drupal under the web root directory.
  *
  * @param $event CommandEvent A instance
  */
 public static function installDrupal(CommandEvent $event)
 {
     $options = self::getOptions($event);
     $webDir = $options['symfony-web-dir'];
     $composer = $event->getComposer();
     $filesystem = new Filesystem();
     $packages = $composer->getPackage()->getRequires();
     $drupal_root = $composer->getConfig()->get('vendor-dir') . DIRECTORY_SEPARATOR . $packages['drupal/drupal']->getTarget();
     $directories = array('includes', 'misc', 'modules', 'themes');
     foreach ($directories as $directory) {
         $originDir = '../' . $drupal_root . '/' . $directory;
         $targetDir = $webDir . '/' . $directory;
         echo sprintf('Creating symlink for Drupal\'s \'%s\' directory', $directory) . PHP_EOL;
         $filesystem->symlink($originDir, $targetDir);
     }
     $directory = 'sites';
     $targetDir = $webDir . '/' . $directory . '/';
     // Check for sites/default because sites/all may exist if composer installs
     // modules or themes.
     if (!$filesystem->exists($targetDir . '/default')) {
         $originDir = $drupal_root . '/' . $directory;
         echo sprintf('Creating new sites directory', $directory) . PHP_EOL;
         $filesystem->mirror($originDir, $targetDir, null, array('override' => true));
     }
 }
开发者ID:bangpound,项目名称:drupal-bundle,代码行数:30,代码来源:ScriptHandler.php

示例14: postActivation

 /**
  * @inheritdoc
  */
 public function postActivation(ConnectionInterface $con = null)
 {
     $fileSystem = new Filesystem();
     //Check for environment
     if ($env = $this->getContainer()->getParameter('kernel.environment')) {
         //Check for backward compatibility
         if ($env !== "prod" && $env !== "dev") {
             //Remove separtion between dev and prod in particular environment
             $env = str_replace('_dev', '', $env);
             $this->webMediaEnvPath = $this->webMediaPath . DS . $env;
         }
     }
     // Create symbolic links or hard copy in the web directory
     // (according to \Thelia\Action\Document::CONFIG_DELIVERY_MODE),
     // to make the TinyMCE code available.
     if (false === $fileSystem->exists($this->webJsPath)) {
         if (ConfigQuery::read(Document::CONFIG_DELIVERY_MODE) === 'symlink') {
             $fileSystem->symlink($this->jsPath, $this->webJsPath);
         } else {
             $fileSystem->mirror($this->jsPath, $this->webJsPath);
         }
     }
     // Create the media directory in the web root , if required
     if (null !== $this->webMediaEnvPath) {
         if (false === $fileSystem->exists($this->webMediaEnvPath)) {
             $fileSystem->mkdir($this->webMediaEnvPath . DS . 'upload');
             $fileSystem->mkdir($this->webMediaEnvPath . DS . 'thumbs');
         }
     } else {
         if (false === $fileSystem->exists($this->webMediaPath)) {
             $fileSystem->mkdir($this->webMediaPath . DS . 'upload');
             $fileSystem->mkdir($this->webMediaPath . DS . 'thumbs');
         }
     }
 }
开发者ID:shirone,项目名称:thelia,代码行数:38,代码来源:Tinymce.php

示例15: doSymlinkAsset

 /**
  * @param $origin
  * @param $target
  */
 private function doSymlinkAsset($origin, $target)
 {
     $this->filesystem->symlink($origin, $target);
     if (!file_exists($target)) {
         throw new IOException('Symbolic link is broken');
     }
 }
开发者ID:liverbool,项目名称:dos-theme-bundle,代码行数:11,代码来源:AssetsInstaller.php


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