CodeIgniter and Sparks, Fatal error: Call to a member function isMobile() on a non-object

codeigniter ellislab

Now this is just going to be a quick tip about a tiny pitfall in the amazing extension system for CodeIgniter: Sparks.

I was lucky to find a spark to detect mobile devices for a project I’m working on right now, so I wouldn’t have to drag together all the specifications for various user agents, written by James Constable. The problem I ran into was, that CodeIgniter would output an error whenever I tried to load the spark, which went like this:

Fatal error: Call to a member function isMobile() on a non-object in /path/public_html/application/controllers/controllername.php on line 35

Turns out, there is a very easy fix for that, which I just didn’t expect to work that way.

Remember the version numbers

Many places and also in the manuals and tutorials I have seen, the version number was not always included, but it seems to be important, so instead of writing:


You just replace that with


and it works like a charm. I’m not sure if this is intendedĀ behaviorĀ in the ways of convention over ease of use, because surely I have to update the loading of sparks with updates, or if it’s something that both accidentally both on my Macbook and my Linux VPS does not work, even though it should, but including the version number is essential.

Try some Sparks?

Well, maybe me reporting an issue about Sparks isn’t the greatest introduction to CodeIgniter and Sparks, but the project is really cool and makes use of developers own git repositories and not a sluggish central service like WordPress Plugin repository. I can only recommend this if you work with CodeIgniter and want to open source some of the stuff you have done or if you’re looking for some cool existing solutions to help you get done faster and with less brain pain.

Thank you for reading! If you have any comments, additions or questions, please leave them in the form below! You can also tweet them at me

If you want to read more like this, follow me on feedly or other rss readers

Leave a Reply

Your email address will not be published. Required fields are marked *