Puli\Repository\FilesystemRepository::isSymlinkSupported PHP Method

isSymlinkSupported() public static method

Returns whether symlinks are supported in the local environment.
public static isSymlinkSupported ( ) : boolean
return boolean Returns `true` if symlinks are supported.
    public static function isSymlinkSupported()
    {
        if (null === self::$symlinkSupported) {
            // http://php.net/manual/en/function.symlink.php
            // Symlinks are only supported on Windows Vista, Server 2008 or
            // greater on PHP 5.3+
            if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
                self::$symlinkSupported = PHP_WINDOWS_VERSION_MAJOR >= 6;
            } else {
                self::$symlinkSupported = true;
            }
        }
        return self::$symlinkSupported;
    }

Usage Example

 protected function setUp()
 {
     if (!FilesystemRepository::isSymlinkSupported()) {
         $this->markTestSkipped('Symlinks are not supported');
         return;
     }
     while (false === @mkdir($this->tempBaseDir = sys_get_temp_dir() . '/puli-repository/FilesystemRepositoryAbsoluteSymlinkTest' . rand(10000, 99999), 0777, true)) {
     }
     // Create both directories in the same directory, so that relative links
     // work from one to the other
     $this->tempDir = $this->tempBaseDir . '/workspace';
     $this->tempFixtures = $this->tempBaseDir . '/fixtures';
     mkdir($this->tempDir);
     mkdir($this->tempFixtures);
     $filesystem = new Filesystem();
     $filesystem->mirror(__DIR__ . '/Fixtures', $this->tempFixtures);
     parent::setUp();
 }