Unstoppable Domains

Organizing Php site

Spaceship Spaceship
Watch

baris22

Established Member
Impact
1
Hello,

I want to organize my php files so i will know where everything is. I want some feedback.

This is my root:

classes
# class.php
# another_class.php

functions
# function.php
# another_function.php

config
# config.php

files
# footer.php
# header.php
# left.php
# right.php
# top.php

images
# logo.gif
# style.css

pages
# about.php
# contact.php
# index.php

index.php
about.php
contact.php

On index.php I have got
PHP:
<?php
$page_title = "title of site";
$page_keyword = "keywords";

define('_This_IS_not-FOR_YOU', TRUE);

include "config/config.php"; // get config
include "files/header.php"; // get header
include "files/top.php"; // get topmenu
include "pages/index.php"; // get content
include "files/footer.php"; // get footer

?>

On pages/index.php I have got

PHP:
<?php defined('_This_IS_not-FOR_YOU') or die('Direct access not allowed.'); ?>
<table width="800" border="1" bgcolor="#FFFF00">
  <tr>
    <td>Index</td>
  </tr>
</table>

On files/header.php I have got

PHP:
<?php defined('_This_IS_not-FOR_YOU') or die('Direct access not allowed.'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $page_title; ?></title>
<link type="text/css" rel="stylesheet" href="images/style.css">
</head>
<body>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Just organize your files the way you feel most comfortable working with them. Nobody else can really tell you how to organize. I will give an example of how i tend to do it so feel free to use similar way of organizing.

Well I tend to organize mine like this.

assets
For public static content like stylesheets and javascript files.

protected
For classes and other backend stuff that public eyes shouldn't need to see. Either protect this with .htaccess or move it outside the web root (recommended).

themes
If you have themes or something.

And then I just have a front controller that handles incoming requests. This is mainly due to my favor of MVC.
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back