The controller/method pair you requested was not found.

A very quick Codeigniter tip this week which will hopefully save you hours of tearing your hair out.

As you can see from the image above I have been writing a command line function and was getting the following error:

The controller/method pair you requested was not found.

This was incredibly confusing as the name I was giving on the command line matched that on the controller – or so I thought. What I actually had in the controller was this:

class kanboard extends CI_Controller {

Turns out that Codeigniter3 expects controller names to have leading caps so changing the … Read the rest

Automatically auditing User Actions with CodeIgniter

One important action you might want to carry out is auditing what actions users have taken in your application. Having this knowledge is useful for working out which functions are being used and in what order. Sometimes users reach functionality in a way you might not have imagined when writing your code. Of course this is also very useful for carrying out support too.

MY_Controller

Fortunately it is very easy to record actions without too much coding and even better you don’t need to add the call to audit into everyone of your functions making a retrofit of user auditing … Read the rest

Styling Codeigniter form error messages

As I get more and more deeply involved in using Codeigniter for my projects I discover bits and pieces that I think might be useful to others.

Today is a very quick tip about styling the error messages that are thrown on a form. Looking at the statement that you have in your view it isn’t immediately obvious how you apply any styling to this at all.

The answer, strangely, is to apply the look and feel through a call to set_error_delimiters in your controller and not in the view. The function takes two parameters: the html code that should … Read the rest

How to run code before every controller in CodeIgniter

I have been working on my side project PostRecycler recently which I have re-written to use the CodeIgniter framework. I came across an interesting challenge where I needed to run some code before every other controller.

What I wanted was to prevent a user from moving away from the dashboard page if their account had expired but what I didn’t want to do was to have to remember to put that into every controller. I guess I could have done it as a helper function but that still would have meant putting a call to it in every controller. MY_Controller … Read the rest

How to store UNICODE in a non-UNICODE database

For a side project I am working on (Glad you asked! PostRecycler which makes the most of your social posts) I needed to all entry of unicode characters for just one field.

This left me in a bit of a quandary as I really didn’t want to have to convert the whole of my database to UTF-8 just so I could have this one column accept unicode characters.

Then I remembered something I had discovered in our companies web app which accepted unicode characters but I knew the database wasn’t unicode enabled. However, I knew that this column was encrypted … Read the rest

Setting the Codeigniter Environment for both CLI and Browser

I’ve recently been getting to grips with the Codeigniter framework after years of using a home-grown monstrosity. I was becoming more and more concerned about the level of security in my own framework and decided I would be better off with something that’s maintained.

I researched the many PHP frameworks to find one that was going to work for me. I toyed with the idea of using Symfony, which is what our products are based on, but the time to get up-to-speed with it was greater than I wanted to invest. I therefore settled on Codeigniter which looked easier … Read the rest