Site Directory Structure - VIew Paths and URL's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
emjayoh
Forum Newbie
Posts: 2
Joined: Sun Feb 03, 2008 8:49 pm

Site Directory Structure - VIew Paths and URL's

Post by emjayoh »

Hi,

I am fairly new at PHP. I am a Front-End Developer who is trying to improve in the back end.

I would like some feedback on the best practice for small to mid sized sites regarding site directory structure.

I have a structure much like this suggested at the Zend website:

Code: Select all

/application
    /config (optional)
    /(module 1)
        /config (optional as needed)
        /controllers
        /models
        /views
    /(module 2)
           /controllers
        /models
        /views
    /(module n)
        /controllers
        /models
        /views
/htdocs
    /images
    /scripts
    /styles
    index.php
/library
    /Zend
    /(other libraries)
/tmp
    /sessions
    /cache
    /view_compiles
 
While I don't have any models, or controllers yet, I am more concerned about managing the many pages a site could produce. Several of the modules would have applications/functionailty associate to them and then this system seams to make sense. But other areas, especially plain old marketing pages of the public site would only logically sit in a parent directory if neccissary.

I am having trouble with understanding how to best place my views.

A more static website structure might look like this:

Code: Select all

/root_web_folder
/_images
/_images/content
/_images/content/content_image.jpg...etc.(photos, illustrations etc.)
/_images/layout
/_images/layout/layout_image.jpg...etc.(backgrounds, buttons etc.)
 
/_includes/
/_includes/all.inc.php
 
/_scripts
/_scripts/all.js
 
/_styles
/_styles/common.css
/_styles/IElte6.css
/_styles/IE7B2P.css
 
/main_section_one/
/main_section_one/index.php...etc.
/main_section_one/all_other_section_pages.php
 
/main_section_two/
/main_section_two/index.php...etc.
/main_section_one/all_other_section_pages.php
 
/index.php...etc.
 
SOOOOOoooooo....

My question is this.

If I take the MVC approached mentioned first, it seems like my URL's will be:

http://domain.com/application/module/vi ... terest.php

Clearly I am missing something here.

In the second example it is clear my URL's would end up:

http://domain.com/section/sub-section/p ... terest.php

Obviously this would produce a nice logically presented URL.

So I am missing some key idea about the distinction of Server Side and Client Side paths.

I realize I don't make a lot of sense here,

Please help!

Thanks
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Site Directory Structure - VIew Paths and URL's

Post by Christopher »

I think you need to understand the differences between pages, scripts and requests. Not every page is a different script. Sometimes a script can be responsible for generating what appear to be several pages. Likewise, a request is a URL that asks for something and is usually comprised of a script name and parameters that tell the script how or what page to build.

Directory structure is a separate matter. You need to organize your scripts, but each script may also need supporting files. The Zend example you show is one way to organized them following the MVC design pattern.
(#10850)
emjayoh
Forum Newbie
Posts: 2
Joined: Sun Feb 03, 2008 8:49 pm

Re: Site Directory Structure - VIew Paths and URL's

Post by emjayoh »

Hey,

Thanks for that initial diagnosis. What are a few key principals that could help me understand this a little better.

I do recognize what you are saying and I understand the principals in general. I few examples would go a long way!

Thanks so much.
Post Reply