Page 1 of 1
Where do you place your files on your webhost
Posted: Mon Mar 15, 2010 12:12 pm
by Rippie
So this is just picking everybodys brains...
When you start a website project, how do you structure your files ? Myself i use:
index.php/html
/images/
/includes/
page1.php
page2.php
page3.php
As you can guess my sites can clutter up quickly and not look as neat as i want it to. so then i thought put all my pages in a /pages/ folder and then just include the pages. but then it is a nightmare in getting links to works across the sites.
How do you do it ?
Thanks in advance !!
Re: Where do you place your files on your webhost
Posted: Mon Mar 15, 2010 12:19 pm
by AbraCadaver
It depends. I normally have one controller file: index.php that includes whatever else is needed. So my links point to index.php and it doesn't matter for the URL where the other files are. If you call separate pages like page1.php, page2.php, etc. then yes it's a mess.
Re: Where do you place your files on your webhost
Posted: Mon Mar 15, 2010 12:53 pm
by flying_circus
I use something like:
../private/project/includes/
/images/
/scripts/ (jscript)
/styles/ (css)
public_page1.php
public_page2.php
public_page3.php
I've been trying to keep all of my php, as much as possible, outside of the webroot.
Re: Where do you place your files on your webhost
Posted: Mon Mar 15, 2010 1:38 pm
by Ragnis
index.php
/modules/page1/module.php
/modules/page2/module.php
/modules/page3/module.php
/includes/
/includes/classes
/images/
/images/css/
/js/
Re: Where do you place your files on your webhost
Posted: Mon Mar 15, 2010 1:45 pm
by saleemawan
It is better to put relevant files in specific folders. Like Image may be placed in image folder while songs may go in songs folder. Its much better to place your program or web files separate from data files.
I do it so and its very easy to manage. This way its more convenient to debug and fix the site problems when needed.
Re: Where do you place your files on your webhost
Posted: Mon Mar 15, 2010 2:27 pm
by pickle
Code: Select all
index.php
someOtherFile.php
basically-any-directly-accessed-file.php
/include
/classes
/templates
/images
/js
/css
/libraries
/stuff-like-SwiftMailer
/-and-Savant3
/etc
Re: Where do you place your files on your webhost
Posted: Tue Mar 16, 2010 6:13 pm
by Rippie
Thank you everyone who replied, it gave me an insight in how others are doing it.
Can I just ask one more question ? Your index file is normally the first page, would you put the first page in the index file ? or will you do your magic and do something like header("location:/pages/main.php"); ?
Kinda trying to figure out if i need a new approach to things.
Thanks in advance.
Re: Where do you place your files on your webhost
Posted: Tue Mar 16, 2010 6:43 pm
by flying_circus
There is a default document directive on the webserver, and it typically points to index.php, index.html, home.html, etc. If none of those filenames are found in the access directory, the server may list the contents of the directory instead.
For consistency and portability, I'd leave index.php as index.php. If you want to get funky, have index.php redirect to pages/main.php if that's how you prefer.
Re: Where do you place your files on your webhost
Posted: Tue Mar 16, 2010 6:48 pm
by Rippie
I leave my index.php the same as you really. not really much too it..
You see i am trying not to get files that is filled with repeated code and not sure if i should use includes for header, menu and footer or if i should use OOP. How do you do it ? just to give me an idea if im completely wrong here .. LOL
Re: Where do you place your files on your webhost
Posted: Tue Mar 16, 2010 6:52 pm
by Rippie
I used to do so i had a script on my index.php that said something like if(isset($_GET['page'])) { include '$_GET['page']'; } else { include 'main.php'; }
That way i did not need to have html headers on my page files but all that was in the index.php
Re: Where do you place your files on your webhost
Posted: Tue Mar 16, 2010 7:27 pm
by Weirdan
Here where I work we use a filesystem layout pretty similar to typical ZF project (
http://framework.zend.com/manual/en/lea ... te-project).