PHP
  Home arrow PHP arrow Building a Site Engine Using PHP, Part...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building a Site Engine Using PHP, Part 3
By: James Murray
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 48
    2004-06-28

    Table of Contents:
  • Building a Site Engine Using PHP, Part 3
  • Wanna Go Out on a Data?
  • Stop Blocking Me
  • Insert Username Here

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building a Site Engine Using PHP, Part 3


    (Page 1 of 4 )

    In this third article of the series, I’ll show you how the database and directories should be set up. I’ll also talk about the how to create, install, and use a content block, which mostly relies on arrays and array functions. I'll cover proper authentication methods for such a project so that multiple sites can run off the same users table in the database, while not barring a username from being used on a site because it is being use on another, all the while keeping the authentication accurate and secure from break-ins. (For part 2, see here.)

    Give Me Direction

    The file system is very important to the site engine. If a directory isn’t named right, the engine won’t know it’s there, in which case it won’t load the files from the directory. So I’ll explain the files system to the best of my ability (since I designed it, my ability should be pretty good). With the help of my friends “Windows Explorer” and “Adobe Photoshop”, I made this little diagram to help explain it all.

    Building a Site Engine with PHP

    Figure 1

    The best way to explain this is to say that the directories labeled in black are the ones that must be labeled the way they are in the diagram; the directories in red are directories that are named depending on what is in them; and the blue is an optional folder in case you have images, CSS, JavaScript, or whatever you want to put in it that’s relevant to your theme. It can be named whatever you want it to be name as long as the theme files know where to look.

    The “ROOT_DIR” directory can be named whatever you would like to be named as long as the server is set up to know where the site engine files are, configure it accordingly to your operating system’s and server’s specifications.

    The “inc” folder should always be named “inc”. This is where all the engine files reside.

    The “plug-ins” directory should always be named “plug-ins”. This is the directory that we’ll be putting all our plug-ins into.

    The “plug-in_name” directory should be named accordingly, based on what plug-in is contained in it. This is also known to the engine as the name of the plug-in. That’s because all the actual plug-in files are named “main.plug.php” so the engine knows the difference by the name of the directory it is in. There needs to be one directory for each plug-in.

    The “blocks” directory should always be named “blocks”. This is where all the blocks that depend on the plug-in, whose directory they are in, reside. Each plug-in directory contains one of these.

    The “modules” block directory should always be named “modules”. This is where all the modules that depend on the plug-in, whose directory they're in, reside. Each plug-in directory contains one of these.

    The “templates” directory should always be named “templates”. This is where all the files that define the templates for each site reside.

    The “site_name” directory should be the same as the host that is defined for the particular site. If your site is hosted at subdomian.url.com the host of the site would be “subdomain”, therefore the directory’s name should be “subdomain” if the site is hosted at www.url.com the host would be "url", therefore the directory’s name would be “url”. There needs to be one directory for each site.

    The “template_name” directory should be named the same as the name of the template. If your template is named “Default” the directory should be named “Default”. There can be multiple templates for each site, but at least one per site.

    The “images” directory can be named whatever you want it to be named. I just included it in the diagram as an example of where you’d put your images, CSS, JavaScript, or anything else the particular template depends on.

    Here is an example of what the directory would look like for the engine running 2 sites, one of the sites having two templates, and five plug-ins, each with a few modules and blocks.

    Building a Site Engine with PHP

    Figure 2

    Note. The two directories that are marked with an asterisk (Fig. 1) can actually be renamed to anything you want, although that’s a rather advanced topic that involves a deeper look into the database, the file system, and the plug-ins and module systems

    That sums it all up for the file system. It’s actually pretty straight forward and painless when you actually start to work with it.

    More PHP Articles
    More By James Murray


     

       

    PHP ARTICLES

    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway