How to make custom helper in CodeIgniter

Custom helper in CodeIgniter
What is Helper?

The helper is used as a function library, by this we can just load a helper class in the controller or view as well. CodeIgniter provide different types of helperclass, such as url_helper, captcha_helper ,email_helper etc. They all are located in system/helper.

We can make as many custom helpers in CodeIgniter. Custom helpers can be made in application/helper directory.


As we know that, a CodeIgniter helper is a PHP file with multiple functions. It is not a class.

Create a file and put the following code into it.

Save this to application/helpers/ . We shall call it “custom_helper.php”

Using the helper

You can load it in your controller, model or view (not preferable)

If you want to use this helper in multiple locations you can have it load automatically by adding it to the autoload configuration file i.e. application/config/autoload.php.

That’s all. You are done!

Enjoy Coding!!

Share This:

One Comment

Leave a Reply