FireworksColdFusionDreamweaverFreehandFlashMXHome
Latest New Content

Latest Free Content
View All
Free Content
Accessibility
CMX Learning Guides
Hosted by enterhost

Code Igniter Introduction

By: Paul Davis

Page 2 of 4

Set for printing

Previous Next

Using Code Igniter

After you download and install it, you read the Getting Started page and then go through the introduction.

No, really, if you spend 15 or 30 minutes reading the introduction manual section for Code Igniter, it will be much easier to use. One of the major assets of the framework is the well documented manual. I read the entire General Topics section when I was evaluating the framework to see if it would meet the needs of the project I was on.

Note: For the company I delivered the project to, it was the only project delivered on time and on budget so far this year.

It is an all-or-nothing set up for your server, so you will either need to set up a sub-domain, get a new domain, set up XAMPP (or some flavor of that) or some other option to secure the needed space for the application. Set up the .htaccess file like the docs say (here). I added some extra things to the htaccess for my sites—I needed a place to put up fully designed pages that haven't been converted to work in Code Igniter or to throw up a file for testing. I also wanted to put my CSS and JavaScript in a different folder and I wanted my included files in a folder, so my htaccess looked like:

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

Code Block 1: Altered .htaccess file

I added the extra folders "playground", "assets" and "includes". These will also allow the files in the view section of the MVC to absolutely path these resources. This way I don't have to guess how to link to them or use a PHP command to make it happen by default.

Code Igniter allows the folder for the entire system to be whatever you want to call it. Once you have it installed and ready in Dreamweaver, your files panel will look like:


Image 1: Code Igniter files

I opened the application folder for this because that is where 99% of the work you will do on the site will be. Specifically, in the controllers and views folder.

Thinking Code Igniter

The way to effectively work with Code Igniter is to think of each task your site will be trying to accomplish. A quick rundown (although not complete) of the tasks my site at Kaosweaver wants to do include:

These are the functions that will be put into controllers. The actual code that creates a search parameter list (gives you options to search by) and shows the results, as well as goes to the details of a product would, logically, fit in one controller. The cart functions, logically, fit in to another. Customer login and product download, another and everything else gets its own controller.

Think about the number of ways the site's look will be presented to the end user. If you have a single looking template for the site, you will only need one view (sort of like a Dreamweaver template) and you can use the controllers to change what is loaded in the view (using the includes). For each different presentation of the site, you create a new view. It is possible to have views include other views (more and more similar to Dreamweaver templates), but, generally, I've used includes to achieve the goal.

Page 2 of 4 Previous 1 2 3 4 Next


download
Download Support Files


Keywords
Code Igniter, PHP framework, PHP, framework, frameworks, mvc