Posted by Daniel in CodeIgniter, SEO, Web Design, Web2.0Jul 31st, 2007 | 5 responses
I have written a few articles on CodeIgniter now because it truly has changed the way I develop websites. It has cut the development time in at least half, preventing redundant work by providing great built-in features that I can use in every one of my projects. Plus, CodeIgniter is so easy to pick up. You can start building CI apps in about 10 minutes after watching the CI tutorials and reading my tutorial on getting set up. If you are new to Object Oriented Programming, you can read my introduction to OOP also.
The way CodeIgniter keeps you organized is this: It keeps everything separate and in their own folders. Just as you would build a website and have an images, css, and javascripts folder so they are separate from the rest of your website, CodeIgniter takes the extra step and organizes your actual website content. CodeIgniter organizes your projects for you with MVC (Model-View-Controller) programming. Here’s the basic structure for MVC projects:
Models
- Interact with your database and return the retrieved data to the controller.
- These are the files you want to build once and not have to edit them ever again. For example, a blog model would include functions to retrieve blog posts and comments, pages, users, page views, etc.
Controllers
- Your controller will load a model, such as a blog model, to retrieve data such as a blog post. You can manipulate the data however you want here and then pass it on to the view.
Views
- Views are what the visitor actually sees. You want this to contain as little PHP and and styling code as possible. This is for your raw content. Use style sheets to style the content and trim the PHP code as much as possible.
Images
Javascripts
- Try to attach your javascript functions to the DOM after the page loads in your javascript file. This way, you can keep your javascript functions out of the views that are for your content, and it helps you program your website to be compatible with browsers that aren’t using javascript.
CSS
- Style your page here. Try to stay away from inline styling. This way, search engines and visitors who are using mobile devices will be able to see your page without styling getting in the way.
.htaccess file
- This file, along with your routes.php file in the CodeIgniter config folder, re-routes your URLs to look pretty. This really helps search engines and visitors remember where pages are on your website. You can get rid of URLs with metadata in them. (http://www.thiswebsite.com/index.php?function=how%20to%20get%20rid%20of%20stupid%20long%20URLs)
Voila. Organized Website Project.
I will accept donations via paypal @ daniel@distributorone.com. Just Kidding.
Thanks to CodeIgniter, MooTools, and new knowledge of how Object Oriented Programming is supposed to work, my projects are much more organized, and I can spend more time being productive because of these tools. Thanks for reading!
Gee I wish I would use it on my site, however I can’t load it on the serveer and the help request on codeigniter forums has gone unanswered doe days now….
what are you having trouble with?
Wonderful Website! I was wondering if I might be able to quote a portion of your pages and use a few things for a term paper. Please let me know through email whether that would be fine. Thanks
Awesome. Thanks for writing this. It is always cool to see someone help out the world.
Some truly fantastic information, Glad I discovered this.