0

Anyone know how to use the Filesystem component Symfony2 to create shortcut files? Or another way to create a file shortcut?

1

1 Answer 1

1
$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

Sign up to request clarification or add additional context in comments.

2 Comments

Actually this may not work with individual files, only directories that contain the files
Failed to create Symlink when i try it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.