Organizing the site structure

Created by Martin Angelov on Jul 25th, 2009

ZineScripts.com

What does it mean?

That means to have your folder structure, configuration files and PHP file structure organized, so that your development doesn’t run into unwanted hold-backs.

The tools

In the development of BloggyBits I used primarily Adobe Dreamweaver. It is not only a great tool for coding, but you can successfully manage your whole development process – from programming to uploading via FTP. So let’s take a look.

We create a new Site

Creating a new Site

We fill in Local Info with all the data needed, after that we must provide data for Remote Info – you can fill in your FTP credentials and you can even choose to automatically upload files on save – a truly useful feature.

The file structure

Below you can see how the BloggyBits file structure is organized.

The file structure

The file structure

As you can see, at the root are only the most important files. You could optimize your root folder even further by creating a CSS and a JS folder for the respective file types.

In the fallowing tutorials we are going to gradually create all those files and make it all work.

The most important thing here is to see how the functionality has been divided among the different files. This allows us to reuse code and have globally accessible configuration in every page of our site.

For example here are the first lines of index.php:

require "connect.inc.php";
require "sess.inc.php";
require "functions.inc.php";

We include three files – for the mysql connection, session handling and the functions we have created for the site. The command require behaves exactly like include (includes the code in the files in the current one), but unlike include it throws a Fatal error and exits your script.

You can even further optimize it if you have a single include file, that handles all your includes.

What are we doing next time?

We start building the HTML & CSS design.

Share:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • StumbleUpon
  • Google Bookmarks
  • DZone
  • Reddit
  • Netvibes

Leave a Reply

Some HTML Tags are OK, Use Entities For The Rest