Logicationz Tech

More Intelligent Solutionz…!

CodeIgniter Subversion Server Change

Our Subversion repositories have moved.  Please update your repositories or check out new ones from the new location: http://svn.ellislab.com/CodeIgniter/trunk

As always, information about our Subversion repositories can be found on the download page and installation instructions.


February 18, 2010 Posted by | CodeIgniter | | Leave a comment

Automatic configbase url

Don’t you just hate it, when you move from development server to production server that you have to change the $config[’base_url’] setting?

Well I do. Because I do it a lot, specially when I’m demoing a web application, that’s why I added this code to the config.php

$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

Once thats added, Codeigniter base_url will adapt to whatever the url you’re using.

Here a version that works for both: http and https:

$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

Or you can just put use this (pretty much the same as above):

$config['base_url'] = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '')

January 29, 2010 Posted by | CodeIgniter, Helpful Tips and Tricks | , , | Leave a comment

Why CodeIgniter HTML helper functions rock

A complaint I often hear about CodeIgniter is one about HTML helper functions like form_open(), doctype() and img().

The complaint boils down to these points:

  • heading(‘Hello’, 1) is ugly compared to <h1>Hello</h1>!
  • Putting HTML in PHP functions is “bad MVC”.
  • My favourite “I know how to write HTML, I don’t need a helper”.

These points of view come from people who do not understanding the potential benefits of using HTML helpers – whichis fair enough as I used to think they were useless too.

Two small things to mention first, then on to the “meat” of the article.

It looks ugly

If you are reading this you are quite likely a programmer who stares at PHP for large amounts of time. Who cares if it does not look as clean as plain HTML in your view files? As far as readability goes, if a designer was to look at heading() im sure it would make perfect sense to them as much as a <h1>.

MVC pattern

Due to CodeIgniter being a MVC framework, people try to apply those three letters to everything. The people who see HTML helpers as “bad MVC” say so mainly because they have HTML outside of the view, which to them “goes against the rules” but I don’t think it should be as cut-and-dry as “ALL HTML ALWAYS GOES IN VIEWS”.

The way I see it is simple, views should contain your custom chunks of HTML (i.e. displaying content, forms, RSS feeds, etc) and helpers/plugins should contain whatever they need to do their helpful job and if that happens to be a small amount of HTML, who gives a damn? It doesn’t “break MVC” in the slightest.

Wrapping your data

The main interest to me comes in the extra abstraction layer these HTML helpers provide you with. The “whats the point?” comments can be answered in the same way as “What’s the point in using jQuery?” or “Why use CodeIgniter over PHP?”. The extra layer of abstraction, combined with helper extending/overriding makes it very easy to change simple bits of logic throughout your application output with minimal fuss.

To explain what the f**k I am talking about, I’ll use an example.

<form action="<?php echo site_url('controller/method'); ?>" method="post">
<?php echo form_open('controller/method');

First you will see the standard HTML way to do it, with the site_url() function used to create the link to the form action. Second you will see the form_open() tag – and in this example its shorter too, wahey!

I wanted a way to set accept-charset=”UTF-8″ in all my forms to help keep my data all <a href=”/news/2009/08/UTF-8-support-for-CodeIgniter”>UTF-8 in CodeIgniter</a>. If I was using just HTML then I would have to go through <strong>all</strong> my forms and add that in myself, which would be wasting time I could have spent at the pub.

Instead, as CodeIgniter allows you to extend helpers, I just made my own slightly modified form_open() inapplication/helpers/MY_form_helper.php which contained this logic. Because I was using PHP to wrap my useful data, I could make one simple change and update all of my <form> tags.

The main problem is people are looking at these HTML helper functions and seeing them purely as different syntax.

Think big

My example shows one useful application of this beyond shorter syntax, but there are plenty more applications for

HTML helper functions.

  • Store your DOCTYPE in a config variable and update your entire site from XHTML 1.1 to HTML 5 easily
  • Developing your app with <h1>Something</h1> then relizing your headers in 500 different view files need <h1><span>Something</span></h1>
  • Fetching metadata from a database and outputting with meta()
  • Adding Google event tracking to images loaded with img()
  • Set your page titles (display headers, not title tag) to use a config variable 1 to 6 in case your CMS needs to change what level the links are.
  • XSS protection for forms using form_open() and form_close(). Derek Allard hinted at this some time ago and I still hope to see it happen.

There are all sorts of crazy things you can do with HTML helpers and while it might be hard to see their value before you have the “aha!” moment, it is a pain to realise you need to use them when it is too late.

January 19, 2010 Posted by | CodeIgniter | , | Leave a comment

Welcome to CodeIgniter!

CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. If you’re a developer who lives in the real world of shared hosting accounts and clients with deadlines, and if you’re tired of ponderously large and thoroughly undocumented frameworks

CodeIgniter is right for you if…

  • You want a framework with a small footprint.
  • You need exceptional performance.
  • You need broad compatibility with standard hosting accounts that run a variety of PHP versions and configurations.
  • You want a framework that requires nearly zero configuration.
  • You want a framework that does not require you to use the command line.
  • You want a framework that does not require you to adhere to restrictive coding rules.
  • You are not interested in large-scale monolithic libraries like PEAR.
  • You do not want to be forced to learn a templating language (although a template parser is optionally available if you desire one).
  • You eschew complexity, favoring simple solutions.
  • You need clear, thorough documentation.
  • December 28, 2009 Posted by | CodeIgniter | | Leave a comment

Download CodeIgniter

CodeIgniter is currently at Version 1.7.1.

Version 1.7.1

Looking for an older version of CodeIgniter? You can download any of the prior releases below. Please note that archived versions are not

CodeIgniter Tutorials

User Guide

Video Tutorials

December 28, 2009 Posted by | CodeIgniter | | Leave a comment

CodeIgniter Community Chieftain Jamie Rumbelow

We’re happy to announce the next CodeIgniter Community Chieftain, Jamie Rumbelow!  This invitation only volunteer program focuses on identifying stellar examples from the community, and letting them utilize their strengths to help maintain the community and act as a liaison when needed to EllisLab. 

Jamie will be taking the reigns from our first Community Chieftain, Michael Wales.  Thanks Mike for your year and a half of volunteer service, and welcome aboard, Jamie!

December 28, 2009 Posted by | CodeIgniter | | Leave a comment

CodeIgniter v1.7.2 Released

EllisLab is pleased to release CodeIgniter version 1.7.2 for ready download.  What’s new?  Among other changes:


  • Compatible with PHP 5.3.0
  • Added a new Cart Class.
  • Improvements to the Form helper
  • Added is_php() to Common functions to facilitate PHP version comparisons
  • Modified show_error() to allow sending of HTTP server response codes, and all internal uses now send proper status codes.
  • Numerous bug fixes

Version 1.7.2 has been baking in the subversion for quite some time, and has been compatible with PHP 5.3.0 since late July, but many users understandably haven’t been running from the in-development version.  While I’d have liked to have had time to add a few more “big ticket” items to this release, making it 1.8, time is a cruel mistress.  Many of our users develop on Macs, and OS X Snow Leopard ships with PHP 5.3.0, so we felt is was more important to push out this stable maintenance release instead of waiting for an even later date – it’s been almost seven months since a refresh, afterall.  But there are still a few good surprises, and welcome changes.  Enjoy!

December 28, 2009 Posted by | CodeIgniter, Uncategorized | | Leave a comment