function Filesystem::symlink
Creates a symbolic link or copy a directory.
Throws
IOException When symlink fails
1 call to Filesystem::symlink()
- Filesystem::mirror in vendor/
symfony/ filesystem/ Filesystem.php - Mirrors a directory to another.
File
-
vendor/
symfony/ filesystem/ Filesystem.php, line 329
Class
- Filesystem
- Provides basic utility to manipulate the file system.
Namespace
Symfony\Component\FilesystemCode
public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false) : void {
self::assertFunctionExists('symlink');
if ('\\' === \DIRECTORY_SEPARATOR) {
$originDir = strtr($originDir, '/', '\\');
$targetDir = strtr($targetDir, '/', '\\');
if ($copyOnWindows) {
$this->mirror($originDir, $targetDir);
return;
}
}
$this->mkdir(\dirname($targetDir));
if (is_link($targetDir)) {
if (readlink($targetDir) === $originDir) {
return;
}
$this->remove($targetDir);
}
if (!self::box('symlink', $originDir, $targetDir)) {
$this->linkException($originDir, $targetDir, 'symbolic');
}
}