Professional CodeIgniter

(singke) #1

Chapter 3: A 10,000 - Foot View of CodeIgniter


52


$active_record = TRUE;
$active_group = “default”;

$db[‘default’][‘hostname’] = “localhost”;
$db[‘default’][‘username’] = “db_username”;
$db[‘default’][‘password’] = “db_password”;
$db[‘default’][‘database’] = “db_name”;
$db[‘default’][‘dbdriver’] = “mysql”;
$db[‘default’][‘dbprefix’] = “”;
$db[‘default’][‘pconnect’] = TRUE;
$db[‘default’][‘db_debug’] = TRUE;
$db[‘default’][‘cache_on’] = FALSE;
$db[‘default’][‘cachedir’] = “”;
$db[‘default’][‘char_set’] = “utf8”;
$db[‘default’][‘dbcollat’] = “utf8_general_ci”;

For now, keep the default values for options after $db[‘default’][ ‘dbdriver’]. As needed, you
will be introduced to them during upcoming projects (e.g., for setting up caching or running debug
sessions).

autoload.php


The autoload.php file specifies which systems are automatically loaded by CodeIgniter. There ’ s one school
of thought that maintains that the autoloader should be kept as minimal as possible to keep the
framework lightweight and nimble, but another school of thought maintains that certain frequently used
systems should be autoloaded instead of called at the local level repeatedly.

You ’ ll find your own balance as experience and local project needs warrant, but for now, set your options
like this:

$autoload[‘libraries’] = array(‘database’,’session’,’email’,’validation’);
$autoload[‘helper’] = array(‘url’,’form’,’text’,’date’,’security’);
$autoload[‘plugin’] = array(‘captcha’);
$autoload[‘model’] = array();
$autoload[‘config’] = array();

The first $autoload option, libraries , is a list of libraries that should be loaded. You ’ re going to be using
the database, session, e - mail, and form validation libraries a lot in this (and many other) CodeIgniter
project(s), thus loading them now makes a good deal of sense. You learn more about these libraries later.

The second $autoload option, helper , is a list of helper collections that you will need to get work done.
Almost every CodeIgniter project uses the URL, form, and text helpers frequently; it ’ s not a bad idea to
have date and security autoloaded as well, particularly as you ’ ll need them to help you parse dates and
handle security features.

For the time being, keep the third $autoload option, plugin , either blank or filled in with the CAPTCHA
plugin, as you may have a need to use CAPTCHA devices in forms for your application for extra
security.
Free download pdf