thomashw Posted June 8, 2010 Share Posted June 8, 2010 Up until now I've built my site right on the server, uploading any changes I've made right away. I recently decided to start doing all development locally and then uploading once it has been tested, etc. I have everything working (Apache, PHP, MySQL, etc. - all through XAMPP) except the paths to different directories/files don't work as they do when they're on the server. For example, on the server: ini_set("include_path","/include"); This works as expected - it finds the proper include folder no matter what directory the .php file is executing from. Locally, though, this doesn't work. I just get an error whenever I try to include a file because it can't find that directory. I tried to use this: ini_set("include_path",$_SERVER['DOCUMENT_ROOT'] . '/include'); but that doesn't seem to work locally either. Does anyone know of a robust way that will ensure paths will work on the server and locally? Quote Link to comment https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/ Share on other sites More sharing options...
ignace Posted June 8, 2010 Share Posted June 8, 2010 You should use set_include_path. Instead of uploading everything to the production server it would be best to run an exact copy of your production server in a virtual-client so that you can correct any error's and not the entire world can see you correct these error's. Quote Link to comment https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/#findComment-1069577 Share on other sites More sharing options...
thomashw Posted June 8, 2010 Author Share Posted June 8, 2010 You should use set_include_path. Instead of uploading everything to the production server it would be best to run an exact copy of your production server in a virtual-client so that you can correct any error's and not the entire world can see you correct these error's. Yes, that's what I'm doing. I'm having trouble getting the paths to work properly locally. I'm talking about all paths, not just the 'include' path. Did you read my post? Quote Link to comment https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/#findComment-1069582 Share on other sites More sharing options...
Maq Posted June 8, 2010 Share Posted June 8, 2010 I tried to use this: ini_set("include_path",$_SERVER['DOCUMENT_ROOT'] . '/include'); but that doesn't seem to work locally either. Does anyone know of a robust way that will ensure paths will work on the server and locally? Did you set the DocumentRoot in Apache? Quote Link to comment https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/#findComment-1069587 Share on other sites More sharing options...
thomashw Posted June 8, 2010 Author Share Posted June 8, 2010 I tried to use this: ini_set("include_path",$_SERVER['DOCUMENT_ROOT'] . '/include'); but that doesn't seem to work locally either. Does anyone know of a robust way that will ensure paths will work on the server and locally? Did you set the DocumentRoot in Apache? Yes I did, and it doesn't seem to work. These should end up being the same, shouldn't they? ini_set("include_path",$_SERVER['DOCUMENT_ROOT'] . '/include'); ini_set("include_path","/include"); Having that preceding forward slash means to go down to the root folder to look for the include folder, correct? It just doesn't seem to be working... The site is located at /Users/thomas/Sites, so I set the document root in Apache to be /Users/thomas/Sites. Quote Link to comment https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/#findComment-1069593 Share on other sites More sharing options...
ignace Posted June 8, 2010 Share Posted June 8, 2010 Like I said you should use set_include_path on Windows platform's the use of ini_set('include_path') does not seem to work (it never did for me and I am not sure about Linux) either way try it Quote Link to comment https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/#findComment-1069643 Share on other sites More sharing options...
thomashw Posted June 8, 2010 Author Share Posted June 8, 2010 Like I said you should use set_include_path on Windows platform's the use of ini_set('include_path') does not seem to work (it never did for me and I am not sure about Linux) either way try it I'll give it a go, but I'm not using Windows. Quote Link to comment https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/#findComment-1069685 Share on other sites More sharing options...
GoneNowBye Posted June 8, 2010 Share Posted June 8, 2010 thanks for this tip - it'll help me too Quote Link to comment https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/#findComment-1069691 Share on other sites More sharing options...
thomashw Posted June 9, 2010 Author Share Posted June 9, 2010 I believe I fixed the problem. The first thing I did was create a virtual host in XAMPP. I then used $_SERVER['DOCUMENT_ROOT'] wherever absolute paths were necessary. This should hopefully allow me to deploy the site without having to change any code beforehand. Here's a helpful link regarding virtual hosts in XAMPP: http://www.acwolf.com/2009/02/24/xampp-virtual-hosts-on-a-mac/ Quote Link to comment https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/#findComment-1069804 Share on other sites More sharing options...
ignace Posted June 9, 2010 Share Posted June 9, 2010 The first thing I did was create a virtual host in XAMPP. I then used $_SERVER['DOCUMENT_ROOT'] wherever absolute paths were necessary. This should hopefully allow me to deploy the site without having to change any code beforehand. When I mentioned a virtual-client I did not refer to a virtual host these are 2 different things. With a virtual-client I meant a program like VirtualBox which allows you to run an exact copy of your server including it's OS. Quote Link to comment https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/#findComment-1069821 Share on other sites More sharing options...
thomashw Posted June 9, 2010 Author Share Posted June 9, 2010 The first thing I did was create a virtual host in XAMPP. I then used $_SERVER['DOCUMENT_ROOT'] wherever absolute paths were necessary. This should hopefully allow me to deploy the site without having to change any code beforehand. When I mentioned a virtual-client I did not refer to a virtual host these are 2 different things. With a virtual-client I meant a program like VirtualBox which allows you to run an exact copy of your server including it's OS. I actually just stumbled upon virtual hosts when I was trying to figure out how to get it to work. This is better anyway, as my site will be portable if I ever change servers. Quote Link to comment https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/#findComment-1069903 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.