Jump to content

PHP - Application Directory Structure (best methods/practices?)


Recommended Posts

Hi all,

Assuming we aren't using a framework like Symphony, CakePHP, CodeIgniter, etc., what do you think is the most logical way to structure our application so that it makes sense, directory-wise?

For example: we will most likely have our own classes and functions that we wrote which we'll need to use, but how should we store them? We would also have a header and footer file most likely, along with other "subpages" - but where do we put them? Do you create a 'library' or 'includes' directory which contain our classes and functions in seperate .php files? Do you create a 'templates' directory that stores our header, footer, etc?

I have a *very* small "application" (if you can call it that) which isn't complex and really only relies on a database for two sections of it. The other sections are simply static files. So to give you an example, let's say I have "Section 1", "Section 2", "Section 3", and "Section 4".

"Section 1" and "Section 2" are going to list a page with various categories, and each category would have multiple pages. Then the user can select an item to view it. I was thinking of just creating an actual "section1", "section2" directory and putting an index.php file in it which lists *all* categories, than maybe a category.php which will list an individual category and its pages. From there I can just have an item.php file, for example, which would show a particular item?

"Section 3" and "Section 4" are just static files, but will have multiple pages. So two folders "section3" and "section4" would have an index.php to list all the "subpages", and then just regular subpage.php, subpage2.php, etc included in it.

I could then use mod_rewrite to rewrite all sections into clean URLs of course.

The application would require classes and a config file as well, however.

But I'm not sure if this is the best method to go about doing these things? What would you do?

Thanks for any help.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.