Question

I'm finding I have lots of conflicts with class names when developing for CodeIgniter. For example, I recently had the situation where I had a Checkout controller:

class Checkout extends Controller 
{
    // Contents
}

And then went on to create a new custom library:

class Checkout
{
    // Contents
}

Which would obviously throw an error.

What I want is to be able to define my controllers as <ControllerName>_Controller so:

class Checkout_Controller extends Controller 
{
    // Contents
}

And I want CodeIgniter to pick this up as it would any other controller. I also want to do this without changing any of the core library so that I can update it without re-implementing my changes again and again.

I know you can do this with routing (and it's how I have been handling it so far) but this seems to me to be more like a hack than an actual solution. Is there a way to force CodeIgniter to use the syntax I want with the restrictions I need?

Was it helpful?

Solution

While this article generally "grinds my gears" it does show you how to the _Controller suffix to your controllers.

http://net.tutsplus.com/tutorials/php/6-codeigniter-hacks-for-the-masters/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top