need help: some advices about webroot structure and organization

need help: some advices about webroot structure and organization

am 11.10.2007 13:36:04 von Francesco

Hi there!
I'm trying to organize my sources into a webroot tree like this,

webroot
index.htm - only contains index.php into a frame
index.php - require_once('inc/layout.php')

home
page1.php - require_once('../inc/layout.php')
page2.php - require_once('../inc/layout.php')
page3.php - require_once('../inc/layout.php')

inc
config.php
layout.php - require_once('redirect.php')
redirect.php - require_once('config.php')


config.php
contains all the settings... the list of pages and other stuff.

layout.php
is the layout used to draw pages.

redirect.php
contains the functions that I use to browse the site.

I have some questions for yoy:

1. is that a good way to structure the site?

2. what about the require_once function?
I mean is it safe to use relative path?

3.What would be te best strategy to manage this structure?

Thanks in advance for your precious help!
Francesco

Re: need help: some advices about webroot structure and organization

am 11.10.2007 14:16:45 von Michael Fesser

..oO(Francesco)

>Hi there!
>I'm trying to organize my sources into a webroot tree like this,
>
>webroot
> index.htm - only contains index.php into a frame
> index.php - require_once('inc/layout.php')
>
> home
> page1.php - require_once('../inc/layout.php')
> page2.php - require_once('../inc/layout.php')
> page3.php - require_once('../inc/layout.php')
>
> inc
> config.php
> layout.php - require_once('redirect.php')
> redirect.php - require_once('config.php')
>
>
>config.php
>contains all the settings... the list of pages and other stuff.
>
>layout.php
>is the layout used to draw pages.
>
>redirect.php
>contains the functions that I use to browse the site.
>
>I have some questions for yoy:
>
>1. is that a good way to structure the site?

No.

1) Why frames?
2) Why a 'home' directory?
3) The 'inc' directory should be stored outside the document root for
security reasons.

>2. what about the require_once function?
> I mean is it safe to use relative path?

I always use absolute paths, based on $_SERVER['DOCUMENT_ROOT']. My init
scripts defines some constants, so it's very easy and convenient to load
files from my different paths.

>3.What would be te best strategy to manage this structure?

This is the usual structure on my sites:

/example.com - the site directory on the server
/etc - configuration files
/include - all the necessary scripts and components for this site
/classes
/modules
/templates
/public - the document root
/css
/images
/scripts
.htaccess
index.php
robots.txt
...

Micha

Re: need help: some advices about webroot structure and organization

am 11.10.2007 15:58:45 von Francesco

Michael Fesser wrote:

> 1) Why frames?
What's wrong with frames? What would be the right way?

> 3) The 'inc' directory should be stored outside the document root for
> security reasons.
I'll do that!

> I always use absolute paths, based on $_SERVER['DOCUMENT_ROOT'].
I wrote another post some days ago about that:
"noob question about document_root"
I'm not able to retrieve the $_SERVER['DOCUMENT_ROOT'] even if phpinfo()
tells me it's setted.

I use easyphp 2.0 beta here and the zend IDE... I don't know if that
does matter.

"
I actually can find the DOCUMENT_ROOT properly set in phpinfo() output

* "Apache Environment" section, as
DOCUMENT_ROOT | c:/.../properPath

* and "PHP variables" section, as
_SERVER["DOCUMENT_ROOT"] | c:/.../properPath
"


My init
> scripts defines some constants, so it's very easy and convenient to load
> files from my different paths.

Do you call init in the index.php page?

Re: need help: some advices about webroot structure and organization

am 11.10.2007 16:12:34 von Jerry Stuckle

Francesco wrote:
> Michael Fesser wrote:
>
>> 1) Why frames?
> What's wrong with frames? What would be the right way?
>
>> 3) The 'inc' directory should be stored outside the document root for
>> security reasons.
> I'll do that!
>
>> I always use absolute paths, based on $_SERVER['DOCUMENT_ROOT'].
> I wrote another post some days ago about that:
> "noob question about document_root"
> I'm not able to retrieve the $_SERVER['DOCUMENT_ROOT'] even if phpinfo()
> tells me it's setted.
>
> I use easyphp 2.0 beta here and the zend IDE... I don't know if that
> does matter.
>
> "
> I actually can find the DOCUMENT_ROOT properly set in phpinfo() output
>
> * "Apache Environment" section, as
> DOCUMENT_ROOT | c:/.../properPath
>
> * and "PHP variables" section, as
> _SERVER["DOCUMENT_ROOT"] | c:/.../properPath
> "
>

And you're getting responses in that thread. Please don't post the same
problem in more than one thread.

>
> My init
>> scripts defines some constants, so it's very easy and convenient to load
>> files from my different paths.
>
> Do you call init in the index.php page?
>

I do the same. I just include the script to get system-defined values.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: need help: some advices about webroot structure and organization

am 11.10.2007 17:00:08 von Francesco

Jerry Stuckle wrote:

> And you're getting responses in that thread. Please don't post the same
> problem in more than one thread.

oh, i'm sorry for that...

>>
>> My init
>>> scripts defines some constants, so it's very easy and convenient to load
>>> files from my different paths.
>>
>> Do you call init in the index.php page?
>>
>
> I do the same. I just include the script to get system-defined values.
>
Thanks for your help!

Re: need help: some advices about webroot structure and organization

am 11.10.2007 20:53:45 von Michael Fesser

..oO(Francesco)

>Michael Fesser wrote:
>
>> 1) Why frames?
>What's wrong with frames?

A lot. "Frames are evil" - you can find a lot of stuff about this topic
on Google and in other web authoring newsgroups.

In short: Frames cause a lot of accessibility and usability problems,
but don't provide real benefits. There are some very rare cases where
frames can be useful, but for most "normal" websites they're not.

>What would be the right way?

No frames, just plain pages.

>> My init
>> scripts defines some constants, so it's very easy and convenient to load
>> files from my different paths.
>
>Do you call init in the index.php page?

It's a bit more complicated here (all page requests are handled by a
single script), but yes, more or less it's like that. On every request
the init script is called/included to setup some important constants for
the other scripts, which will then handle the request.

Micha