This is NOT a basic Codeigniter tutorial, but rather a reminder of the steps to take when setting up a new CI installation.
-
Basic Installation
- Download the latest version (2.1.2 at time of writing).
- If you are working with a Cpanel web server, upload the zip file to the server and expand it. It will expand into it’s own directory.
Otherwise , simply unzip and upload to where ever you like. - Move the user help files to a local directory. They are simply a repeat of the manual available on the Codeigniter web site.
- Delete the readme, license.txt and everything except the index.php
- Create a folder, preferably above the web root, and move the system and application folders into it
- Edit index.php
Add this right at the start
date_default_timezone_set(‘Pacific/Auckland’);
change
l.59
$system_path = ‘system’;
to
/home/username/folder/system/
l. 75
$application_folder = ‘application’;
to
/home/username/folder/application/Go to index.php and you should see: - Create another folder for publicly accessable assets – css, images, js. I called mine “public”
- Create a .htaccess file for this folder with this code, to prevent any php being executed from these folders
<Files .htaccess> order allow,deny deny from all </Files> SetHandler Do_Not_Remove_See Options None Options +FollowSymLinks
- Create a .htaccess file with this code for the public root of your site, ie the folder where you have your index.php
<Files .htaccess> order allow,deny deny from all </Files>
RewriteEngine on RewriteCond $1 !^(index\.php|public|robots\.txt) RewriteRule ^(.*)$ index.php?/$1 [L]
- Edit application/config/config.php
$config[‘index_page’] = ‘index.php’;
to
$config[‘index_page’] = ”;$config[‘uri_protocol’] = ‘QUERY_STRING’;
to
$config[‘uri_protocol’] = ‘AUTO’;l. 282 $config[‘global_xss_filtering’] = TRUE;
$config[‘compress_output’] = TRUE;
$config[‘rewrite_short_tags’] = TRUE;
- application/config/autoload
Turn on your favourites at this stage, eg database and url - application/config/database.php
Set the driver to mysqli, and enter your database details -
Set up HMVC
- Download and unzip the fiiles from https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home
- Put MY_Loader.php and MY_Router.php into the core folder
- Put the MX folder into third_party
- Put this into config.php
$config['modules_locations'] = array( APPPATH.'modules/' => '../modules/', );
- Create a folder – applications/modules
- Create a folder within modules with then name of your module in lowercase
- Within that folder, create folders for models, views, controllers and whatever esle you will be writing
- Create a file for the first controller with the same name as the folder. The class should also have the same name, but with an initial capital letter
- Edit applicaation/config/routes.php to point to this controller by default
- Add any files you normally start with, eg styles.css with your reset (minified) at the top, and your favourite media query breakpoints defined, a folder in the views to contain template components
- Zip up the entire installation and save it as your boilerplate for future productions