Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > CodeIgniter Hows and Whys

CodeIgniter Hows and Whys
Thread Tools
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jan 6, 2010, 11:53 PM
 
I received a PM asking me to elaborate on how I use CodeIgniter, so here goes...

CodeIgniter is a PHP framework that makes certain things in PHP far easier to do. It is very similar to JQuery or Prototype in this regard, for those (like me) that can't live without one or the other.

One of the main things CodeIgniter enforces is an MVC (or model video controller) approach to programming, where your code's logic (controller) is separated from its view (html display). Using both one or more controllers and views is required with CodeIgniter, although models aren't, unlike some other PHP frameworks.

Separating my code from my HTML is a *huge* benefit. Those of us that have these big long hard-to-read pages that jump back and forth between PHP and HTML will know that these can be a complete PITA, especially when it comes to finding where brackets start and stop, and tracing where these HTML snippets are called from.

In addition to MVC programming, CodeIgniter provides a whole bunch of additional functions which are available for your usage, optionally, that have saved me tons of development time. These are all well documented in the CodeIgniter user guide.

My sites marry CodeIgniter with WordPress. You can actually load the entire WordPress environment with a single include statement, which is what I do on the first line of all of my CodeIgniter sites. This allows me to put WordPress template tags in my views and call them as I wish, but it also allows me complete control over my sites in my CodeIgniter controller. This means I don't have to mess around with WordPress theme files or assigning templates to pages.

The other question that was asked was about how I manage my rotating banners. I do this with a combination of Prototype and Script.aculo.us. I don't like to include configuration variables in my Javascript, so I set this up in my CodeIgniter configuration file and make this data available to my Javascript functions via a JSON string. My Javascript banner rotate library reads the names of the files, and sets these as CSS background-images to the div block where my banners rotate.

I hope this helps!
     
Big Mac
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status: Offline
Reply With Quote
Jan 7, 2010, 03:49 PM
 
Sounds pretty cool. I only know of CodeIgniter in the context of it being integrated into the next major release of ExpressionEngine. I'm still not entirely sure what that will provide to EE, but the developers seem to be excited about the prospects so I'm interested.

"The natural progress of things is for liberty to yield and government to gain ground." TJ
     
turtle777
Clinically Insane
Join Date: Jun 2001
Location: planning a comeback !
Status: Offline
Reply With Quote
Jan 7, 2010, 03:55 PM
 
Good stuff

... although I have no clue what this is about

-t
     
besson3c  (op)
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jan 7, 2010, 04:54 PM
 
I should have added that Ruby on Rails is all about MVC, so PHP frameworks like CakePHP and CodeIgniter should make Ruby users feel right at home.
     
besson3c  (op)
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jan 7, 2010, 04:59 PM
 
Originally Posted by Big Mac View Post
Sounds pretty cool. I only know of CodeIgniter in the context of it being integrated into the next major release of ExpressionEngine. I'm still not entirely sure what that will provide to EE, but the developers seem to be excited about the prospects so I'm interested.
Go to the CI user guide:

Welcome to CodeIgniter : CodeIgniter User Guide

click on the table of contents tab and you'll see a listing of classes and helpers. The items listed in the list will give you a sense as to what CI makes easier. In addition to that, URL routing, dynamic loading of resources, logging, etc. are all very useful.

In short, if you are building a web app or even just a regular site where a fair amount of code will be involved, I recommend a framework such as CI for code simplification and organization.
     
Big Mac
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status: Offline
Reply With Quote
Jan 7, 2010, 05:01 PM
 
So I gather you can use it to extend the native functionality of CMSs, like you describe and as EE 2.0 implies.

What's your view on DOM, besson? A lot of seemingly knowledgeable people say that PHP is good but the interaction you have to use with DOM to make certain rich functionality possible makes things much worse. True? And for that matter, what about AJAX?

"The natural progress of things is for liberty to yield and government to gain ground." TJ
     
besson3c  (op)
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jan 7, 2010, 05:12 PM
 
Originally Posted by Big Mac View Post
So I gather you can use it to extend the native functionality of CMSs, like you describe and as EE 2.0 implies.
Not really. CodeIgniter provides a different environment for writing code in, and it provides you with some ready-made classes and helpers to reduce the amount of code you have to write. However, you still have to write the code to utilize all of this, CI is not some sort of turnkey set of plugins to existing apps or something. There is nothing CI does that you couldn't do yourself in pure PHP. Same goes with CakePHP, the other PHP toolkits based on CodeIgniter, etc.

What's your view on DOM, besson? A lot of seemingly knowledgeable people say that PHP is good but the interaction you have to use with DOM to make certain rich functionality possible makes things much worse. True? And for that matter, what about AJAX?
DOM, the document object model? I'm not sure what this argument is? This might be the fact that in pure PHP the logic and display (which would include the generation of a page's DOM) is intertwined, which can indeed be problematic without a toolkit such as CodeIgniter. I'm not sure if this is what the argument entails though...

As far as AJAX goes, PHP or other middleware languages like it have little to do with AJAX. AJAX is Javascript-driven, not PHP-driven. For making AJAX calls I recommend a toolkit such as Prototype or JQuery. Doing this in pure Javascript is no fun.
     
hyteckit
Addicted to MacNN
Join Date: May 2001
Status: Offline
Reply With Quote
Jan 7, 2010, 05:50 PM
 
If you are interested in the strict PHP5 OOP, you might want to check out kohana PHP.

Home – Kohana: Swift, Secure, and Small PHP 5 Framework

It's a fork of codeigniter.

Also, there is a lot of interesting things going on with the Yii Framework.

Yii PHP Framework: Best for Web 2.0 Development

Codeigniter has the best documentation, if you are interested in using a PHP framework.

For ajax/javascript framework, look into jquery, extjs, and yui. I know there are many others.

extjs is more for web application developer, but requires a commercial license if you want to sell your web application.

For something similar to extjs for web application development, but works like Objective-C, you might want to take a look at cappuccino.

Cappuccino Web Framework - Build Desktop Class Applications in Objective-J and JavaScript

I'm working on codeigniter, exijs, and adobe air.
Bush Tax Cuts == Job Killer
June 2001: 132,047,000 employed
June 2003: 129,839,000 employed
2.21 million jobs were LOST after 2 years of Bush Tax Cuts.
     
besson3c  (op)
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jan 7, 2010, 05:55 PM
 
Yeah, the widely anticipated Gallery 3 (Gallery | Your photos on your website) is based on Kohana.

For AJAX calls I still prefer Prototype. It is very Ruby on Rails like, and a lot of Javascript based widgets are already using it. I don't like that it pollutes the global namespace though, and some have complained about the documentation (I don't mind it), but if you already have stuff using Prototype you won't have to load anything else.

Script.aculo.us also uses Prototype, which I also use. Script.aculo.us is a little long in the tooth now, but I haven't found anything I like better for animation. Last I checked Apple is still using both Prototype and Script.aculo.us on their site. You can definitely use a combination of Prototype and Script.aculo.us to do a lot of the stuff that people used to do in Flash, including my rotating banners I included a link to in the CSS tips thread.
     
hyteckit
Addicted to MacNN
Join Date: May 2001
Status: Offline
Reply With Quote
Jan 7, 2010, 06:04 PM
 
Originally Posted by besson3c View Post
Yeah, the widely anticipated Gallery 3 (Gallery | Your photos on your website) is based on Kohana.

For AJAX calls I still prefer Prototype. It is very Ruby on Rails like, and a lot of Javascript based widgets are already using it. I don't like that it pollutes the global namespace though, and some have complained about the documentation (I don't mind it), but if you already have stuff using Prototype you won't have to load anything else.

Script.aculo.us also uses Prototype, which I also use. Script.aculo.us is a little long in the tooth now, but I haven't found anything I like better for animation. Last I checked Apple is still using both Prototype and Script.aculo.us on their site. You can definitely use a combination of Prototype and Script.aculo.us to do a lot of the stuff that people used to do in Flash, including my rotating banners I included a link to in the CSS tips thread.
Apple uses a lot of Dojo in the web store. I don't care for Script.aculo.us anymore. Shifting focus to jquery instead. Hoping the Jquery UI will come close to extjs in terms of available UI widgets soon.
Bush Tax Cuts == Job Killer
June 2001: 132,047,000 employed
June 2003: 129,839,000 employed
2.21 million jobs were LOST after 2 years of Bush Tax Cuts.
     
besson3c  (op)
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jan 7, 2010, 06:19 PM
 
Care to provide me with some cool animation examples using jQuery? I'd love to see what can be done and compare implementations...
     
besson3c  (op)
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jan 7, 2010, 06:29 PM
 
While we are talking about style and techniques and stuff (and I'm enjoying this thread!), I'd also like to add that I'm very big on not including any inline styles or Javascript on the page itself and including all of this externally. Using one of the aforementioned JS toolkits it is very easy to attach observers either to individual IDs in the DOM, or else looping through items using selectors such as:

$$('#myphotoalbum .photo')

You can use a Javascript console in Webkit/Safari or Firebug to select items to ensure that your selection is as expected.
     
hyteckit
Addicted to MacNN
Join Date: May 2001
Status: Offline
Reply With Quote
Jan 7, 2010, 06:49 PM
 
Originally Posted by besson3c View Post
Care to provide me with some cool animation examples using jQuery? I'd love to see what can be done and compare implementations...
Some animation effects:

jQuery UI - Demos & Documentation
Bush Tax Cuts == Job Killer
June 2001: 132,047,000 employed
June 2003: 129,839,000 employed
2.21 million jobs were LOST after 2 years of Bush Tax Cuts.
     
Andy8
Mac Elite
Join Date: Apr 2003
Location: Hong Kong
Status: Offline
Reply With Quote
Jan 7, 2010, 07:23 PM
 
Originally Posted by hyteckit View Post
Some animation effects:

jQuery UI - Demos & Documentation
Very interesting.
     
besson3c  (op)
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jan 7, 2010, 07:25 PM
 
Looks like a lot of the same sort of effects you can do with Script.aculo.us, but I hate that Script.aculo.us does this with inline styles... Does jQuery work the same way? For instance, if you want to do a fade in, do you have to set the display:none to your element first?
     
hyteckit
Addicted to MacNN
Join Date: May 2001
Status: Offline
Reply With Quote
Jan 8, 2010, 01:14 AM
 
Originally Posted by besson3c View Post
Looks like a lot of the same sort of effects you can do with Script.aculo.us, but I hate that Script.aculo.us does this with inline styles... Does jQuery work the same way? For instance, if you want to do a fade in, do you have to set the display:none to your element first?
Click on "View Source". There's only like 40 lines of code for the whole example with all the effects.
Bush Tax Cuts == Job Killer
June 2001: 132,047,000 employed
June 2003: 129,839,000 employed
2.21 million jobs were LOST after 2 years of Bush Tax Cuts.
     
andi*pandi
Moderator
Join Date: Jun 2000
Location: inside 128, north of 90
Status: Offline
Reply With Quote
Feb 5, 2010, 03:36 PM
 
Lots of good stuff with latest jquery:

The 14 Days of jQuery
     
iMOTOR
Mac Elite
Join Date: Jan 2003
Location: San Diego
Status: Offline
Reply With Quote
Feb 23, 2010, 05:45 AM
 
Originally Posted by besson3c View Post
One of the main things CodeIgniter enforces is an MVC (or model video controller) approach to programming,
Not to nitpick, but don’t you mean Model View Controller, not video?
     
besson3c  (op)
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Feb 23, 2010, 06:16 AM
 
Heh, yeah... video was a dyslexic moment
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 05:29 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,