0
votes

I use symbolic links in my web project. There is a source folder and an additional folder for an email task which is executed by a service.

Both the website and the task are written in PHP and use my util.php, sql_functions.php and config.php files.

Rather than hardcoding the locations of these three files, I created symbolic links to these three utility files and some directories so that they are available from each of my subdirectories. The code works.

I also created a batch file which automatically creates these links and documented the installation procedure.

Below you can find a screenshot of the folder that contains my email task. sql_functions.php loads the configuration data and is being used by email.php to access the SQL Server. The symlink to the sql folder also helps.

All of these folders are in the same repository, so there is no real risk that any dependencies might not be loaded.

It just feels like dirty programming.

file explorer

1

1 Answers

1
votes

Although symbolic links by themselves shouldn't be harmful to the understanding and maintaining of the codebase, your case in kind of brutal. Puting a symlink in everyone of your files looks like overkill there. There are more options than just choosing betwen hardcodes paths and such a violent solution.

For example, you could set the path of these files in a constant that is loaded at the begining of each files through a require(), or many others solutions. In the end, it depends on the way your website works, but I doubt your solution is the most flexible you could come up with.