Getting The Environment Set Up
Last time, we installed the software and altered the config.php file by adding two lines (one commented out). Please review Getting Started With CodeIgniter – 1 for details.
If you now visit the home page running locally on your PC, you should see this. Obviously you must substitute your root directory where I have used chaingang3.
Setting up database.php
Most web sites demanding the attentions of CodeIgniter will need a database. I am using MySQL. I created a MySQL database called chaingang3 and set up a username and password for it.
To communicate this to the CI system, edit the database.php file located in the config directory (same place as the config.php file was located).
Add the following lines to database.php, but of course use your own username, password and database name. The placeholders for these parameters are already in the file, you just have to fill in the values.
$db[‘default’][‘hostname’] = "localhost";
$db[‘default’][‘username’] = "myusername";
$db[‘default’][‘password’] = "mypassword";
$db[‘default’][‘database’] = "chaingang3";
Setting Up constants.php
I like to place any constants that I need to have available throughout the web site in the constants.php file. So early in your development you won’t know what these are for the mostpart, but each time you need a new global constant, set it up in here. To start with I will put in the Version number of the site I am developing. This is the site’s 3rd version so I’ll make a suitable constant, and add it to constants.php.
Setting Up Custom Functions
As you code, you’ll need to write PHP functions. There is a special place to put these in CI. Go to system/application/helpers and create a custom helper PHP file with a name like mycustomfunctions_helpers.php.
As time goes on, you’ll add more of your own functions to this file.
To do this, create all your required sub-directories under the CI application directory in a new sub-directory called assets. Of course you don’t have to call it assets – I do because someone on the CI forums suggested the name. Anyway – I set the following structure up and so I’ll always have somewhere specific to place required files.