I have been trying to improve my dev/live workflow recently to get 1:1 parity. I want everything to work the same on Dev (my local machine) as it does on live (the Web). Aside from having a different config file (containing different mySQL credentials) and a different .htaccess file, I want the rest of the site to work exactly the same on my live environment as it does on my dev environment. The problem is I cannot get my include paths to resolve the same way on both environemnts.
I have all of my includes configured in this format:
Include path
$_SERVER["DOCUMENT_ROOT"] . /website1/includes/file.php
The problem is that on my LIVE server, $_SERVER["DOCUMENT_ROOT"]
does not contain the /website1/ part, but on my TEST server, it does. That means the paths resolve differently on the two environments:
Live:
/some/root/folder/website1/includes/file.php
Dev:
/some/root/folder/website1/website1/includes/file.php
I've worked around this somewhat by copying the included files into a subfolder called /website1 for use in the MAMP dev environment. But this is clearly not ideal as it adds unnecessary overhead. Whenever I edit one of the included files, I have to be sure to edit the file in both locations.
Does anyone have any suggestions for making the include paths the same on both environments, without duplicate files? I have tried using dirname(__FILE__)
, but that would require making alot of changes so that relative paths can resolve. I tried various other solutions such as trying to change the include path via .htaccess, httpd.conf or php.ini, but nothing seems to be working. I know there must be a simple solution, but I'm lost. Ideally I'd like any configuration change to be to the local environment so as to avoid tampering with the live environment.
Much appreciated!