Anyone know how to use the Filesystem component Symfony2 to create shortcut files? Or another way to create a file shortcut?
1 Answer
$filesystem = new Symfony\Component\Filesystem\Filesystem;
$filesystem->symlink($originDir, $targetDir, $copyOnWindows = false);
Reason to use Symfony Filesystem over the native PHP symlink would be because this method will prepare the directory for you, converts triggered errors into exceptions, and manages compatibility on Windows which doesn't support symlinks, so creates a copy instead.
Source: https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Filesystem/Filesystem.php#L289
2 Comments
Adam Elsodaney
Actually this may not work with individual files, only directories that contain the files
user3075249
Failed to create Symlink when i try it