Back to blog

List all controllers and methods in Codeigniter


Use the following library to list all Controllers and methods of a Codeigniter application. You could use it for information about your application or to protect controllers and methods with an ACL plugin for example.

Get it at my Github repository!

Copy the file to your application/library directory and you’re ready to use it in any of your controllers.

Usage:


//
// a Controller
//
function showList() {
    $this->load->library('controllerlist'); // Load the library
    print_r($this->controllerlist->getControllers());
}

Call the controller for example:

mydevelopment.local/controller/showList

It will show you an array of controllers and their methods.

Labels: codeigniter php

8 Responses

  1. ahmed sherif on March 20, 2013

    thank you so much

  2. i am trying to implement acl for codeigniter and for that i need all the available methods and controllers. Your post helped me to sort out that problem. Thank you.

  3. I am not able to view the controllers list.
    When I am tring to load the library it is showing blank page.
    I am using codeigniter 1.7

    • Peter Prins on October 25, 2013

      It’s for version 2 and higher. I recommend to upgrade anyway!

  4. Hi Peter thanks for your response. I tried some other method to list all controllers for below 2.0 versions.I am posting that link here, It may helps someone

    http://stackoverflow.com/questions/2797495/how-to-get-an-array-of-all-controllers-in-a-codeigniter-project/2801866#2801866

  5. robin on January 2, 2014

    Thanks buddy. I appreciate your work done

  6. This is a great piece of work and solves the Big problem I have when developing which is quick and easy access to all the methods I’m trying out. Thanks for sharing

  7. anggitpy on January 21, 2017

    Thanks, I really need this
    just in case you need to use it in CI3:

    Usage of the EXT constant has been deprecated since dropping support for PHP 4. There’s no longer a need to maintain different filename extensions and in this new CodeIgniter version, the EXT constant has been removed. Use just ‘.php’ instead.

Drop a note