NYCPHP Meetup

NYPHP.org

[nycphp-talk] FUNDAMENTALS #1: Site Structure

Brian Pang bpang at bpang.com
Fri Sep 5 16:27:03 EDT 2003


great responses from all so far.

I have to admit, that most of the time, I use a subdirectory, but a
parallel directory does make sense from a security standpoint.


Using .inc is just way too confusing for me, so mine all get .php
.inc doesn't tell me what language I'm dealing with, nor does it give
good syntax coloring, at least not automatically.


Regarding portability, at the beginning of every file I put
require_once($_SERVER['DOCUMENT_ROOT'] . "/LIB.php");

where LIB.php sets some variables for me, like the location of includes,
images, functions, webroot/domainname, classes, etc. as $INCLUDES,
$FUNCTIONS, $IMAGES, $WEBROOT, etc

I then use these everytime I call on an include or require a function
require("$FUNCTIONS/nameOfFunction.php");

This way I can move from machine to machine and put those dirs whereever
I want or am able. This really helps when you only have access to the
www directory and can't use a parallel directory.


Looking forward to reading the final review/synopsis on this first column.



> FUNDAMENTALS #1: Site Structure:  Where to Locate Includes?
> 
> Index.php is always located in a website's document root, /var/www/html/
> on 
> a Linux box.
> Where should includes be located?
> 
> Here are some possibilities:
> * in the same directory, /var/www/html/
> * in a subdirectory of document root, /var/www/html/includes/
> * in a parallel directory to document root, /var/www/includes
> 
> What are the advantages and disadvantages of each possibility?
> IN THE SAME DIRECTORY
> * simple
> * but confusing and cluttered if there are more than just a few
> IN A SUBDIRECTORY
> * provides a logical place for them
> * but exposes them to browsers
> IN A PARALLEL DIRECTORY
> * provides a logical place for them
> * doesn't expose them to browsers
> * but perhaps write privileges are not available (or needed?)
> 
> What does exposure matter?
> If the include file contains html, it will be visible in the calling
> file's 
> source code.
> If it contains php code (like a database connection), it will never be 
> visible anyway.
> 
> Are there important principles here, or is location just a matter of 
> preference?
> 
> =======================================================================
> Don't know what this posting is all about?
> See: http://lists.nyphp.org/pipermail/talk/2003-September/005049.html
> =======================================================================
> 
> Jeff
> 
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
> 
> 






More information about the talk mailing list