2

Installing BackendPro on Multi-Site CodeIgniter

Posted (Updated ) in PHP

Out of the box CodeIgniter only supports MVC. Today I’ll explain how we can convert that to HMVC for some nice, modular goodness. This tutorial follows on from CodeIgniter with Multiple Sites, and I’ll be using that tutorial as a base so make sure you’ve read up on and understand how it works before continuing. There are several libraries available for converting CodeIgniter to HMVC – namely Wiredesignz’s Modular Extensions, however today we’ll be using BackendPro 0.6.1 (latest as of time of publication) on CodeIgniter 1.7.2 as it provides a range of goodies for us to play with such as user authentification and asset management.

Firstly you’ll need to set up a fresh, multi-site CodeIgniter installation then download BackendPro from here. Extract BackendPro to its own folder. You should now have a folder with the following contents:

BackendPro Folder Contents
BackendPro Folder Contents

Copy the assets, install, modules and user_guide folders into your CodeIgniter installation. Your CodeIgniter installation folder should now look like so:

CodeIgniter Installation Folder After Copy
CodeIgniter Installation Folder After Copy

Back in your BackendPro folder, copy all files in the system/application directory to your CodeIgniter installation directory replacing all as you go (routes.php seems to be the only file overwritten).

Before we can install we’ll need to make two more tweaks. Firstly in config/matchbox.php change:

$config['directories'] = array('../../modules');
//to
$config['directories'] = array('modules');

and secondly – if you’re using a .htaccess file to route all URLs through index.php as I am, you will need to add ‘install’ to the exception list

RewriteEngine on
 
RewriteCond $1 !^(index\.php|assets|install|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

We’re now ready to install BackendPro. Browse to your site:

http://localhost/tutorial/install

You’ll be greeted by the BackendPro installation screen. In the CodeIgniter File Section set
System Folder to system
Application Folder to blank
Modules Folder to modules
Log Folder
to system/logs (Or preferrably just logs to keep logs site specific – you’ll need to make a folder)
Cache Folder to system/cache

In all other sections enter your information as required. Hit the install button to complete installation. This may just be my quirkly PHP installation (caused by xDebug?), but to get it to install correctly I needed to modify install/components/FileSystemCheck.php and change

include_once("common/CommonFunctions.php");
//to
include_once(dirname(__FILE__)."/../common/CommonFunctions.php");

Upon successful installation delete your install folder and you’re good to go.