Site Configuration: CodeIgniter

From Wikipedia of the Dark Jedi Brotherhood, an online Star Wars Club
Real World Perspective.

The Dark Jedi Brotherhood leverages CodeIgniter (CI) as its PHP MVC framework. Because the DJB site is far from simple, the specifics of the CodeIgniter implementation is detailed below.

If you are a developer for the Dark Jedi Brotherhood or you have aspirations to be one, learning all about CI is required. You can find documentation here. I highly recommend Jeffrey Way's video tutorials.

Structure

The Brotherhood's site uses the standard CI application structure:

Directory Description
application Base application folder
- cache Contains cached files (This is currently not used by the DJB)
- config CodeIgniter and Custom configuration settings for the DJB site
- controllers The files found in here control what models to instatiate, what business logic to execute, and what templates to render
- core Files in here are auto-loaded and override/extend core classes found in /system/core
- errors Holds error pages. (This is currently not used by the DJB)
- helpers Files in here (always appended by _helper.php) contain functions and classes that are made available at a global level in the application
- hooks Files in here allow for code insertion in core Code Igniter. (This is currently not used by the DJB)
- language Alternate language files. (This is currently not used by the DJB)
- libraries The files in here contain classes that extend or enhance the CodeIgniter framework for the DJB
- logs Logs!
- models The files in here contain the core business logic of the DJB. The classes represent site objects (e.g. Members, Prestige, Units, Credits, Possessions, etc)
- third_party The files and directories in here are from external locations (e.g. Smarty, dBug, etc)
- views These are the DJB's template files
css Stylesheets
js JavaScript libraries
images Images. Enough said.


Smarty Parser

Rather than mixing pure PHP with HTML, the DJB leverages the Smarty Templating Engine (version 2). Smarty does not work cleanly with CodeIgniter out of the box, so the following files have been added to support the templating engine:

File Description
config/smarty.php Configuration settings for Smarty
third_party/smarty/ Smarty v2 code
libraries/Smarty.php Base class to initialize smarty
libraries/Tpl.php Extends the class defined in libraries/Smarty.php and adds a boatload of custom DJB features
libraries/DJB_Parser.php Extends the CodeIgniter Parser object to leverage Smarty AND a template wrapper that is custom to the DJB


Config

I'm not going to list all of the configuration files...just ones that we've tweaked/added.

File Description
autoload.php Specifies which helpers, libraries, models, config, etc files to load automatically.
cache.php Configuration settings for memcached caching
config.php Application specific core CodeIgniter configurations. No parameters have been added...just tweaked.
database.php Database configuration settings.
email.php Parameters for sending emails
routes.php This is where you map the URI to controllers (when you don't want to use the default mapping). A good example of this is what we're doing with the auth controller (i.e. Instead of going to /auth/login to log in, the site directs you to /core/login....there are more instances of that sort of thing)
smarty.php Smarty configuration settings
tank_auth.php Settings for the Tank Auth library that we use for authentication


Controllers


File Description
auth.php Handles authentication, registration, password and email resets.
base.php A dumb controller that redirects traffic that lands on the webroot to /core
core.php Controls the front page and various simple, logic-free pages.
guide.php Controls the rendering of guide pages


Core


File Description
DJB_Router.php Extends CI_Router to change all URIs whose specified class and/or method contains dashes to use underscores instead


Helpers


File Description
combined_resource_helper.php Provides a method for grabbing the current version of merged JS and merged CSS files.
djb_autoload_helper.php Used to autoload PSR-0 style DJB APIs found in the models/DJB directory
table_helper.php Includes a class (used by instantiating statically) to abstract out table names.
tools_helper.php Includes a class to be instantiated statically. The class is a tool for doing a boatload of general purpose stuff.


Libraries


File Description
Cache.php Library to enable reading/writing to both memcache and apc cache
DJB_Parser.php Extends the CodeIgniter Parser object to leverage Smarty AND a template wrapper that is custom to the DJB
phpass-0.1/ PHP password hasher
Smarty.php Base class to initialize smarty
Tank_auth.php Core library for the Tank Auth plugin that manages account creation/logins/password resets/etc.
Tpl.php Extends the class defined in libraries/Smarty.php and adds a boatload of custom DJB features


Models


File Description
DJB/ DJB objects in PSR-0 style.


Third Party

Views