Where do you place your files on your webhost

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
Rippie
Forum Commoner
Posts: 76
Joined: Sun Jan 10, 2010 11:32 am
Location: Nottingham

Where do you place your files on your webhost

Post 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 !!
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Where do you place your files on your webhost

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Where do you place your files on your webhost

Post 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.
User avatar
Ragnis
Forum Commoner
Posts: 31
Joined: Thu Nov 13, 2008 12:35 pm
Location: Saaremaa, Estonia, Europe, Asia, Planet Earth, The Solar System, Milky way.

Re: Where do you place your files on your webhost

Post by Ragnis »

index.php
/modules/page1/module.php
/modules/page2/module.php
/modules/page3/module.php
/includes/
/includes/classes
/images/
/images/css/
/js/
User avatar
saleemawan
Forum Newbie
Posts: 4
Joined: Mon Mar 15, 2010 1:50 am

Re: Where do you place your files on your webhost

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Where do you place your files on your webhost

Post 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
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Rippie
Forum Commoner
Posts: 76
Joined: Sun Jan 10, 2010 11:32 am
Location: Nottingham

Re: Where do you place your files on your webhost

Post 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.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Where do you place your files on your webhost

Post 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.
Rippie
Forum Commoner
Posts: 76
Joined: Sun Jan 10, 2010 11:32 am
Location: Nottingham

Re: Where do you place your files on your webhost

Post 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
Rippie
Forum Commoner
Posts: 76
Joined: Sun Jan 10, 2010 11:32 am
Location: Nottingham

Re: Where do you place your files on your webhost

Post 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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Where do you place your files on your webhost

Post 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).
Post Reply