I was recently working on moving some PHP software from one server to another for a client of mine and ran into a spot of trouble.

The previous developer that was maintaining the software and the “production” environment is a mate of mine so I won’t bag him too much in public, although he knows who he is and the pain he caused me .. lol ^_^

Anyway suffice to say the move did not go 100% according to plan. Even with many years of experience deploying websites and running Linux servers, I was not really ready for what I was about to face.

You see I originally installed this Debian server many moons ago (back in the day when Q-mail Rocks was the set up to have) and in good Virgo fashion I left it in a very nice and ordered state in the hands of my mate. The server subsequently had a couple more guru Linux cooks brew a few concoctions up on it.

Anyway the point of all this drivel is that my mate and the other cooks in their infinite wisdom had decided that the humble symbolic link was the weapon of choice to ensure proper and extensive (and I mean extensive) “code reuse”.

Let me tell you it was like moving a house of cards from one table to another.  In there were symlinks that linked to other symlinks which in turn were symlinks to development files. WTF???

There were image directories that had symlinks to other image directories which in turn had symlinks back to the original image directory. You should have seen the size of the tar files it was trying to create! Anyway lets just say an accurate description would be a bowl of spaghetti crossed with a spider web made by mr crack spider.

I am still finding missing symlinks but have since found this cool bit of code that re-curses through the directory tree and finds all the broken symlinks.. yay!!

for i in `find ./ -type l`; do [ -e $i ] || echo $i is broken; done

Anyway there are plenty of better ways to re-use code kids. Symbolic linking is not really the most maintainable option!

Think before you symlink!