Home arrow PHP arrow Building a Site Engine Using PHP, Part 3

Building a Site Engine Using PHP, Part 3

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.)

TABLE OF CONTENTS:
  1. Building a Site Engine Using PHP, Part 3
  2. Wanna Go Out on a Data?
  3. Stop Blocking Me
  4. Insert Username Here
By: James Murray
Rating: starstarstarstarstar / 48
June 28, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: