Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/204206-paths-development-vs-deployment/
Share on other sites

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.

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?

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?

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.

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.

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/

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.