I have a shared hosting plan and do not know much info about server setup. I am looking for a way to set up a project root directory. For example, on my domain in the root level, I have my website, however, I have a directory called "projects" and in here I have individual directories for each project. In these directories is where I do some of my development work. How can I set up a $root variable in each of these directories so that I can reference things only in that directory?
Something globally has to be set somewhere. I've googled and found suggestions, for how to get what directory I am in and such, however I don't see the purpose in this because the code people are suggesting would have to be on a file somewhere, thus I would need to call this file somehow (ie. ../config.php, ../../../config.php, ../../../../../../../config.php). Please help!
Thanx in advance.
Project Root Directory
Moderator: General Moderators
-
bigbstanley
- Forum Newbie
- Posts: 4
- Joined: Sat Mar 04, 2006 11:48 am
- Location: Fort Lauderdale, FL
Re: Project Root Directory
Hi bigbstanley
Have you thought about using include/require from files? They most likely ways to reference in php. Am I with you?
Have you thought about using include/require from files? They most likely ways to reference in php. Am I with you?
-
bigbstanley
- Forum Newbie
- Posts: 4
- Joined: Sat Mar 04, 2006 11:48 am
- Location: Fort Lauderdale, FL
Re: Project Root Directory
yeah, I am using includes. however, this is where maybe I am not seeing the solution - my code to include a config file would be something like:
<? include('settings/config.php'); ?>
That is great if I'm on the project root directory. However, then for every other page that set in a deeper directory I would have to reference it differently:
<? include('../../../settings/config.php'); ?>
I guess I'm looking for something that PHP will read automatically in any directory before rending any HTML. I also work a lot with Coldfusion and in any directory a file named "application.cfm" is read first before any rendering is done. The "application.cfm" also carries through any subfolder hierarchy unless it comes across another "application.cfm". I've read some stuff about the php.ini files but it doesn't make too much sense to me. Those are server settings, I just want to set a variable for a directory, call any file in that directory and it would know that variable.
<? include('settings/config.php'); ?>
That is great if I'm on the project root directory. However, then for every other page that set in a deeper directory I would have to reference it differently:
<? include('../../../settings/config.php'); ?>
I guess I'm looking for something that PHP will read automatically in any directory before rending any HTML. I also work a lot with Coldfusion and in any directory a file named "application.cfm" is read first before any rendering is done. The "application.cfm" also carries through any subfolder hierarchy unless it comes across another "application.cfm". I've read some stuff about the php.ini files but it doesn't make too much sense to me. Those are server settings, I just want to set a variable for a directory, call any file in that directory and it would know that variable.