Page 1 of 1
PHP Site Structure
Posted: Wed Oct 29, 2008 6:35 am
by cjconnor24
Please excuse me if this is the wrong category (this is my first post on here).
I have
just started getting into PHP and have bought a few books to learn about creating database driven websites. However, i can't seem to find out the best way to structure the actual folders on my server when using includes.
Could anyone offer any advice?
I've noticed on a few sites people appear to use a folder for each page (or at least this is what it looks like to my untrained eye):
http://www.thewebsite.com/about/
http://www.thewebsite.com/products/
http://www.thewesite.com/contact/
you get the idea, im sure.
Any help would be much appreciated and i hope, once i learn a bit more, to be able to contribute to this forum
Thanks,
C
Re: PHP Site Structure
Posted: Wed Oct 29, 2008 7:49 am
by panic!
They are probably using Model View Controller.
Where each of those urls probably doesn't relate to a real folder on the file system, but relates to a model name (which is probably the name of a table on the database).
So the url
http://www.site.com/product/edit/1
is
model/action/id
or maybe
http://www.site.com/product/view/ball-point-pens
is
model/action/parameter
all of these will be passed into index.php (probably) and it will work out how and which things to display.
the Model View Controller pattern might be a bit complex for a total beginner but if you can get to grips with it then great!

Re: PHP Site Structure
Posted: Wed Oct 29, 2008 7:54 am
by cjconnor24
wow, yeh i think that probably is a bit out of my reach at the moment!!!
Could anyone then recommend the best course for me to take when structuring my site?
Thanks, again, in advance

C
Re: PHP Site Structure
Posted: Wed Oct 29, 2008 7:56 am
by panic!
I'd say to begin with, if it's a small project, do how feels best to you...but learn from your mistakes...you will make many.
Re: PHP Site Structure
Posted: Wed Oct 29, 2008 12:20 pm
by josh
You will probably find rewrite rules of some interest
Re: PHP Site Structure
Posted: Wed Oct 29, 2008 2:59 pm
by Eran
Those are most likely just url beautification and not actual folders. This can be achieved using two methods: url rewriting at the server level (apache has
mod_rewrite) or parsing at the script level (
here is a nice tutorial for url beautification in PHP).
Re: PHP Site Structure
Posted: Fri Nov 21, 2008 12:10 pm
by EPX
It all depends on the type of site your make, or should i say the size.
If you have a small site (up to 50 pages) that you want people to find on google, try and keep all the files in the root with excetion to images, css, pdf's and other such files which should be in sub folders. Google doesn't like drilling to far down sub folders.
if you have a bigger site, it's difficult to manage sites using just the root directory. so i would only recommend only going up to 2 sub directories deep.
Try and keep directory stuctures simple.