"Toby Miller" <[EMAIL PROTECTED]> wrote:
> While it is true that you don't have to put your files in the web
directory
> at all and it is a more secure option there is still one very large
> inconvenience that prevents me from going with that option. You lose the
> usefulness of just including "$DOCUMENT_ROOT/yourfolder/yourfilename".
This
> is the main reason that I do put my files in the root web directory. So
how
> do you tell all of your files where your included content is? Do you hard
> code the path in every page? If so, do you also have development, stage,
and
> live environments that mimic the exact same directory structures? If not,
do
> you always change the include strings by hand every time you move from one
> environment to another? Do you run into these problems? What kind of
> solutions/workarounds have you implemented?

Here's a solution I've used with a lot of success.  I concocted it myself a
year or so ago after trying a number of other alternatives.

// Set INC_PATH.
ereg( '(.*)htdocs.*', $SCRIPT_FILENAME, $regs );
define( 'INC_PATH', $regs[1] . 'inc/' );

// Include files.
include( INC_PATH . "inc_common.php" );
...
include( INC_PATH . "inc_db.php" );

Nearly all of the sites I design are controlled from a single PHP file using
some Apache AliasMatch magic so I usually only have to set the INC_PATH
constant
in one file and include the main include files in the same place. So the
include directory (inc) is parallel to my web docs directory.  The parent of
both is a directory called 'production', which has directories parallel to
it called 'development' and 'staging' which allows me to run 3 versions of
the site, each on 3 separate ports and copy code from one version to the
other and run them with no modifications.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to