How do you organize your files?

How do you organize your files for your website??

I’m doing basic procedural programming. (No fancy OOP or MVC stuff, so no show-offs!!)

Also, I am trying to put as much stuff into a MySQL database as possible.

Even with that, there are a lot of “one-off” files that are mucking up my Document Root.

For example, I have…

[INDENT]


index.php
log_in.php
create_account.php
workshops.php
my_account.php
contact_us.php

[/INDENT]…and so on.

Questions:
1.) Should I file away those odd, “one-off” files into new directories (e.g. “account”, “help”, “Admin”)?

2.) Should I leave them in the Document Root?

3.) Should they somehow go into my database?

4.) Other?


My website will be content-heavy, so a lot of things will fit into my database (e.g. Articles, Case Studies, Interviews, How-To’s). However, it is becoming obvious that there are a lot of other web pages that don’t have a good “home” currently.

How do MEGA-sites like SitePoint, Yahoo, CNN, etc do things?

Thanks,

Debbie

You’ll find there is no right or wrong way to organise your files as it also depends on the size (total number of all files) of your website.

For “small” websites I put all the web pages (php, html etc) in the root directory . I then have sub directories called lib (for javascript files), images (for image files), stylesheets (for stylesheets). Under the lib directory I have a directory called includes for php include files and a directory called classes for php class files.

For larger websites I will have additional directories and sub-directories to suit.

First of all I would like to ask you why not OOP and MVC? They make the (programming) life much much easier as far as I know. But if you are still go for this normal structural programming and want to manage the files, then see how I would go for:
Document Root - all the PHP/HTML files that are accessed from URL (browser’s address bar) i.e. index.php, about.php, etc.
include - all the including files like header.php, footer.php, left.php (which are included in the main files index.php, about.php, contact.php)
js - all the javascript files
images - all the images
css - all css files
library - all the PHP files that are not directly accessed from browser but included instead i.e. functions.php. Also all the third party codes/classes i.e. fpdf, phpmailer, etc.
library/classes - all the classes that you developed if you have any (just to segregate from other include files.

I don’t say best one but would cover and show the difference of the files :wink:

Because I have never been able to understand OOP and MVC to the point where I would feel comfortable building a real website using them. (Any idiot on the Internet can write OOP and MVC, but in my experience 95% of those people haven’t a clue what they are doing… I choose to use a simpler, more traditional approach until I can do the newer methods the correct way…) :wink:

But if you are still go for this normal structural programming and want to manage the files, then see how I would go for:
Document Root - all the PHP/HTML files that are accessed from URL (browser’s address bar) i.e. index.php, about.php, etc.
include - all the including files like header.php, footer.php, left.php (which are included in the main files index.php, about.php, contact.php)
js - all the javascript files
images - all the images
css - all css files
library - all the PHP files that are not directly accessed from browser but included instead i.e. functions.php. Also all the third party codes/classes i.e. fpdf, phpmailer, etc.
library/classes - all the classes that you developed if you have any (just to segregate from other include files.

I don’t say best one but would cover and show the difference of the files :wink:

I am basically doing what you suggest now. If I add additional folders by “functional grouping” (e.g. myaccount, help, workshops, etc) am I helping or hurting things?

It just seems like as my website grows, that if I have everything “that you can access from the URL” (as you say) I could still easily have dozens - if not hundreds - of files in my Document Root?! :blush:

On a related note, what do mega-sites like CNN, USAToday, Yahoo, etc do to manage files? (They certainly would have to expand your approach?!)

Do they put every webpage into a database?

Thanks,

Debbie

Though I cannot guarantee what they have done exactly because I have never been a developer of CNN, Yahoo, etc. yet :stuck_out_tongue: But I am almost sure that they manage all the contents (or webpage in your word) in database. I don’t think that there will be problem on keeping the more than 100 files in the document but if you are flexible calling them then that’s indeed not a bad idea to categorize the files and keep them in different folders but it will increase the rules to be written for rewriting the URLs if you want later on.