Best page structure with classes

A

Anonymous

Guest
it's no matter how you create structure of the some project.
main that you remember what in UNIX and in Windows use different case sensitive folder and if you are have folder like InCLUDE and you are asking about include - it's a different things. bun in windows system it's no matter.
 
Well: from my experience it would be better for you to use one file called common.php that will include everything needed and do all the checks.

that file will be included on every page so that you dont hav to include 10 files on each page.
It is also good to have a structure with directories for modules, each module in its own dir, includes -- main core files, each file should do its own job (sessions, auth, mail, rss and so on), templates -- with different themes.

Its a pretty global explanation of the dir structure: but its up to you to decide how you are going to create it.
 
That's it Soulshine99, Alexei said everything!
I can give you a little example (from one of my files):
Code:
<?php 

define('IN_SITE', true);
require_once('common.php');

$site->SetPageTitle('Hi! I am an empty page!');
$site->SetScript('js/functions.js', 'text/javascript');
$site->ShowHeader();

?>
Empty page!
<?php $site->ShowFooter(); ?>
So, as you can see, all the main files (classes) are included and all objects created in the common.php file.
If you're using folders you can use PHP's include_path directive to set the full path to your include directory. This way, and like in this example, you can call for the "common.php" file in your root or inside a folder.

Hope it helps!
 
possible also to define $app_root_path that will be a global variable . it will help on some systems.
hehe.. pretty hard to explain everything like this: but i think you will figure it out very soon :)

Good luck!
 
You have lots of open source apps out there... just download one and take a look at it :)
Take a look at this tutorial.
 
Back
Top