|
|
CodeIgniter Hows and Whys
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
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!
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Jun 2001
Location: planning a comeback !
Status:
Offline
|
|
Good stuff
... although I have no clue what this is about
-t
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Originally Posted by Big Mac
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.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Originally Posted by Big Mac
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.
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: May 2001
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: May 2001
Status:
Offline
|
|
Originally Posted by besson3c
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.
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Care to provide me with some cool animation examples using jQuery? I'd love to see what can be done and compare implementations...
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: May 2001
Status:
Offline
|
|
Originally Posted by besson3c
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.
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Apr 2003
Location: Hong Kong
Status:
Offline
|
|
Originally Posted by hyteckit
Very interesting.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
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?
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: May 2001
Status:
Offline
|
|
Originally Posted by besson3c
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.
|
|
|
|
|
|
|
|
Moderator
Join Date: Jun 2000
Location: inside 128, north of 90
Status:
Offline
|
|
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2003
Location: San Diego
Status:
Offline
|
|
Originally Posted by besson3c
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?
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Mar 2001
Location: yes
Status:
Offline
|
|
Heh, yeah... video was a dyslexic moment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|