Don't be lazy, use ln

I am building a small MVP project using PHP, so rather than fighting with brew and config files, I am running MAMP locally as a quick way of getting PHP and Apache and MySQL and etc all bundled in a thing you run easily.

So I was trying to create a symbolic link from the MVP's public folder to the MAMP htdocs folder and I lingered in the realisation that the existing links I had created in the past looked like macOS 'aliases' in the Finder, or what people in Windows call a 'shortcut', which is also what I call them because the first time I learned about that concept I was using Windows too.

In a moment of weakness and laziness, I thought: what if I just create this new link using the macOS 'make alias' function?

To do that you right click over the item you want to alias, and select 'Make alias'. So I right clicked over public and made an alias. Which is initially called public alias by macOS.

Then you drag the newly created alias (which has a little arrow in the bottom left corner in its icon) to the final place you want it to be (i.e. MAMP's htdocs folder). You can even rename it to whatever you want, and it will keep pointing to the original item. So I renamed it to MVP, because public alias was just not very nice.

Then you hope that if you access http://localhost:8888/MVP MAMP will start serving the original public folder contents.

Except... it didn't.

My browser kept getting sent a 912 bytes download... which on inspection seems to be the literal alias file.

It seems like when macOS creates an alias, it isn't like the aliases you create with ln -s. I.e. it is not a 'proper' UNIX style symbolic link. It is a literal binary file. Which Apache was happily sending to my browser. And I don't blame it. What else could it do, if it appeared like a file to it?

So I thought: OK, being lazy caused more work than otherwise. Let's do the proper thing that I should have done from the beginning: use ln -s in the command line:

# i.e. ln -s source_folder destination_link
ln -s /Users/sole/data/projects/MVP/public/ /Users/sole/data/projects/htdocs/MVP`

This creates another MVP item in the htdocs folder, with an arrow in the bottom left corner of the icon, like the alias I created earlier. Except this time IT WORKS!

Anyway!

This works now! But just in case you try to be lazy and think macOS will help you to create your htdocs aliases: no, it won't. Don't fall in the same trap I did!

PS a quick search indicates that the advantage of macOS aliases is that they can follow when the source file gets moved (how, I do not know and didn't want to research). I wouldn't mind that macOS add their own features, but it is very deceitful that the Finder renders both symbolic links and aliases the same way. DECEITFUL, I tell you! Boo macOS.