2

PHP symlink() function fails on Windows 7 with the error:

Warning: symlink(): Cannot create symlink, error code(3) in C:\xampp\htdocs\…\lib\model\doctrine\Website.class.php

It's a XAMPP server on with PHP 5.3.8.

From the symlink() documentation:

5.3.0 This function is now available on Windows platforms (Vista, Server 2008 or greater).

Any ideas/suggestions?

Ain Tohvri
  • 2,987
  • 6
  • 32
  • 51

3 Answers3

3

Might be a bug in PHP 5.3 according to this:

https://bugs.php.net/bug.php?id=48975

and this:

http://forum.wampserver.com/read.php?2,64011 (reply #2)

Maybe you could upgrade to PHP 5.4 and see if it works?

  • Thanks for the suggestion, we'll give it a run shortly. – Ain Tohvri Nov 14 '12 at 10:57
  • Absolute niceness, it worked! XAMPP update to the PHP version 5.4.7 fixed it. Thanks a lot Alex! – Ain Tohvri Nov 14 '12 at 11:27
  • Alex, if you have a spare minute, I'd appreciate if you took a look at another case/bug with symlinks on Windows 7 http://stackoverflow.com/q/13379645/1373324 Could be that you've experienced this as well. – Ain Tohvri Nov 14 '12 at 13:26
0

I use this

//symlink($target, $link);
exec('mklink /j "' . str_replace('/', '\\', $link) . '" "' . str_replace('/', '\\', $target) . '"');
B.Asselin
  • 978
  • 10
  • 19
  • The option `/j` creates symlinks to folders - for files (as needed in this case) use `/H` instead - see: http://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/ – HumanInDisguise Oct 05 '15 at 08:39
0

About PHP CLI on windows OS:
Do not forget to start the console with Run as Administrator else symlink will return false and raise the following error:

Warning: symlink(): Cannot create symlink, error code(1314)
Nabi K.A.Z.
  • 9,887
  • 6
  • 59
  • 81