Where do you place your files on your webhost
Moderator: General Moderators
Where do you place your files on your webhost
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 !!
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 !!
- 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
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.
- 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
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.
../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.
- 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
index.php
/modules/page1/module.php
/modules/page2/module.php
/modules/page3/module.php
/includes/
/includes/classes
/images/
/images/css/
/js/
/modules/page1/module.php
/modules/page2/module.php
/modules/page3/module.php
/includes/
/includes/classes
/images/
/images/css/
/js/
- saleemawan
- Forum Newbie
- Posts: 4
- Joined: Mon Mar 15, 2010 1:50 am
Re: Where do you place your files on your webhost
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.
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
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
/etcReal programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Where do you place your files on your webhost
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.
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.
- 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
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.
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
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
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
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
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
Here where I work we use a filesystem layout pretty similar to typical ZF project (http://framework.zend.com/manual/en/lea ... te-project).