NYCPHP Meetup

NYPHP.org

[nycphp-talk] FUNDAMENTALS #1: Site Structure

David Sklar sklar at sklar.com
Thu Sep 4 10:10:02 EDT 2003


> FUNDAMENTALS #1: Site Structure:  Where to Locate Includes?

I set things up like this:

Document root: /www/www.sitename.com/docroot
Includes:      /www/www.sitename.com/support

Individual pathnames and directory names, of course, don't really matter,
but it's important to locate includes outside of the document root. You can
configure your web server to not server include files based on extension or
parse include files as PHP based on extension, but then you're in trouble if
you ever have an include file with a different extension (on purpose, by
accident, because you edited one in-place with emacs and ended up with
foo.inc~, etc.)

Putting includes outside of the document root also lets you put other things
in that include directory: PHP scripts that run not as a response to
requests (cron jobs, other maintenance scripts, etc), other programs, data
files that aren't PHP, etc.

Dividing things like this makes it easier to group files into CVS modules
that are used for different purposes. For example, let's say things are
organized like this:

Document root: /www/www.sitename.com/docroot
Includes for database access: /www/www.sitename.com/support/db
Includes for site layout and formatting:
/www/www.sitename.com/support/layout
Scripts run by cron: /www/www.sitename.com/support/cron
Textfiles containing data feeds: /www/www.sitename.com/support/feeds

Each of these directories can be a separate CVS module. If you have a
machine that just needs to run cron scripts (which themselves need database
access), you can just check out (or export) the support/db and support/cron
modules on that machine instead of all the code. Other combinations can be
similarly modular. If everything is piled under the document root, you don't
have that kind of flexibility.

David




More information about the talk mailing list