There are many usecases for symbolic links but one time they are a must is when developing your own composer packages.
When developing packages; you will want to be able to test the code in another project. First problem you might encounter is git repo inside another gitrepo = submodules. So easiest after cleaning up that mess is to move your package outside of testing package.
Now you want to be able to run composer update and install it like normal, but you also dont want to run composer update every time you did a change. You also do not want to edit inside the vendor folder since that would mean you copy files manually back to the original folder.
The solution to all of the above is symbolic links, which come in two variant on windows, NTFS junction points or symbolic links. NTFS junction points can only be used on directories, symbolic links can be created to all files but only by administrators.
Here is an example:
- In composer.json of the test project, include a path to your package.
"repositories": [{
"type": "path",
"url": "./../silentridge/my-vendor-package",
"options": {
"symlink": true
}
}],
- This will fail probably because on windows only admins can create symlinks. This can be changed by
- win+run write
secpol.msc
+ enter - Goto:
Local Policies -> User Access Management -> Create Symbolic Links
- In there you can add your user or you can add your entire group, mine looks like this
DESKTOP-patrik\Users
- Ok and apply.
- Run composer update and you got a symlink to your other folder and can use it as a composer dependency.