News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Phil Sturgeon's Blog:
CodeIgniter Base Classes Keeping it DRY
February 11, 2010 @ 09:46:51

In a new post to his blog Phil Sturgeon looks at creating sharable code for your controllers in a CodeIgniter application (DRY: Don't Repeat Yourself).

The idea is that most of your controllers share something in common with each other. For example: All admin controllers need to make sure a logged in user is present and that they are an administrator. A public controller may want to load a theme for your application and load default user data, navigation links or anything else frontend related.

The problem is solved by creating a base controller - in his example its one called MY_Controller that follows the CodeIgniter naming convention and allows you to easily make other controllers that extend it. You'll also need to make a small addition to your config.php file to get the base controllers working correctly and make them able to be found.

0 comments voice your opinion now!
codeigniter base class controller dry


blog comments powered by Disqus

Similar Posts

Refulz Blog: Traits in PHP 5.4 - Why we need Traits

Richard Heyes' Blog: SMTP class rehash

Felix Geisendorfer's Blog: Making error handling for Model::save more beautiful in CakePHP

Felix Geisendorfer's Blog: Assert the yummyness of your cake

DevShed: Using Introspective Methods with the DirectoryIterator Class in PHP 5


Community Events





Don't see your event here?
Let us know!


interview framework release podcast community conference library series laravel voicesoftheelephpant introduction api list developer symfony language zendserver bugfix tips deployment

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework