Step 0: Upgrade your library

If you're using subversion, its super easy!!

cd mysite/www/ rm -rf lib svn co http://svn.osotite.com/trunk/BaseJumper-v2.1/lib/

Otherwise, hit up the download page to get the source. Unzip it into your folder and you're good to go.

Step 1: Convert to Config system

Replace all define()'s with Config::set, and all defined variables with Config::get. Here is a list of all the defines used in BaseJumper that may be in your classes:

  • AMAZON_AWS_KEY
  • AUTH_SECRET
  • BASEJUMPER_INSTALLED
  • BJ_TRACK_CACHE
  • COPYRIGHT_AGENT
  • CRON_REQUEST_IP
  • DB_HOST
  • DB_PASS
  • DB_USER
  • DB_TRACK
  • DEFAULT_IMAGE_PATH
  • DEFAULT_IMAGE_FILE
  • DEFAULT_IMAGE_WIDTH
  • DEFAULT_IMAGE_HEIGHT
  • FCK_BASEPATH
  • FCK_CONFIG
  • GOOGLE_MAP_API_KEY
  • IMG_DATA_DIR
  • IMG_ORIG_DIR
  • MAILER_FROM
  • MAILER_FROM_HOST
  • MAILER_FROM_SENDER
  • MINIMUM_AGE
  • SITE_ADMIN
  • SITE_BASEURL
  • SITE_HOSTNAME
  • SITE_JURISDICTION
  • SITE_NAME
  • SITE_OWNER
  • SITE_WEBPATH
  • SMS_FROM_EMAIL
  • THIN_IMAGE_PATH
  • USE_MOD_REWRITE
  • USERS_MUST_ACTIVATE
  • YAHOO_APPLICATION_ID

Please note: in moving to the Config system, all of these have changed internally to lower case, so AUTH_SECRET becomes Config::get('auth_secret'). You dont have to follow this convention in your code, but I highly suggest it.

//this.... define('SITE_NAME', 'My Site'); //becomes.. Config::set('site_name', 'My Site'); //and this... if (defined('FOO')) //becomes... if (Config::get('foo'))

One of the reasons for the switch to Config, is that it is notoriously difficult to keep track of all your defines... there is no easy way to search for defined variables being used, whereas with Config::set, and Config::get, it is trivial to find all the usages of config data in your site. To help you find lingering defines, try this regex:

egrep '[A-Z_]{3,}' * > old-defines

Step 2: Add all used modules to BaseJumper

This can be accomplished in a variety of ways. The easiest way, is to add the modules in via your BaseJumper constructor with the addModule() function. Here is an example:

public function __construct() { parent::__construct(); $this->addModules(array( 'Foo', 'Bar', 'FooComment', 'FooThread' )); }

A quick an easy way to do this is to do a grep on your include directory to get all the classes. Then just do some vim magic on them to format them in PHP array style, and you're good to go.

grep class *.php > modules

Step 3: Set your site as being installed.

A new feature to BaseJumper, which is intended to ease the installation process, is an installed flag. By setting this, you are saying that your site is installed, and everything is good to go. This should go in your config.inc.php file.

Config::set('basejumper_installed', true);

Step 4: Use the Mail singleton.

The global $mailer variable has been removed. Instead, use the singleton class Mail which has the same interface, without the dangers of global variables.

Search for it:

grep -Hirn 'global \$mailer' *

Replace it:

//this... require_once("lib/mail.inc.php"); global $mailer; $mailer->mail($to, $from, $body); //becomes Mail::send($to, $from, $body);

Step 6: Autoload sanity check

Double check to make sure that you are requiring lib/autoload.inc.php first in your include/global.inc.php file. The order should be: Autoload, Config, then Db, then all your module registrations

Step 7: Use some new features. (optional)

BaseJumper 2.1 adds some cool features like caching and whatnot. Its nice to be able to see it working and get a glimpse at the internals. There are a couple functions you can use to automatically add that, they are implemented in BaseTemplate, and are easy to use. The first is drawGenerationStats which draws stats about how long it took to make the page, how many queries, and how many cache hits, and the second is drawRecachePageLink which draws a link to recache the page, if the whole thing is cached in the first place.

//simply add it wherever you want in your template $this->drawGenerationStats(); //a footer is generally a good spot for this. $this->drawRecachePageLink();