title: How do I get a list of all functions inside a controller in cakephp
body: <p>I needed to select a controller in <a href="http://cakephp.org" rel="nofollow noreferrer">CakePHP 2.4</a> and display all the functions written in it. I found how to list controllers from this question &amp; answer thread on <a href="https://stackoverflow.com/a/898206/576523">Stack Overflow</a> but what I need now is given a specific controller I need to get the list of all functions it contains.</p>
  
  <p>Here what i have done </p>
  
  <pre><code>public function getControllerList() {
  
     $controllerClasses = App::objects('controller');
     pr($controllerClasses);
     foreach($controllerClasses as $controller) { 
  
        $actions = get_class_methods($controller);
        echo '&lt;br/&gt;';echo '&lt;br/&gt;';
        pr($actions);
  
     }
  }
  </code></pre>
  
  <p>pr($controllerClasses); gives me list of controllers as follows</p>
  
  <pre><code>Array
  (
      [0] =&gt; AppController
      [1] =&gt; BoardsController
      [2] =&gt; TeamsController
      [3] =&gt; TypesController
      [4] =&gt; UsersController
  )
  </code></pre>
  
  <p>however pr($actions); nothing... :(</p>
  
  <p>here you go the final working snippet the way i needed</p>
  
  <p><a href="http://www.cleverweb.nl/cakephp/list-all-controllers-in-cakephp-2/" rel="nofollow noreferrer">http://www.cleverweb.nl/cakephp/list-all-controllers-in-cakephp-2/</a></p>
  
  <pre><code>public function getControllerList() {
  
          $controllerClasses = App::objects('controller');
          foreach ($controllerClasses as $controller) {
              if ($controller != 'AppController') {
                  // Load the controller
                  App::import('Controller', str_replace('Controller', '', $controller));
                  // Load its methods / actions
                  $actionMethods = get_class_methods($controller);
                  foreach ($actionMethods as $key =&gt; $method) {
  
                      if ($method{0} == '_') {
                          unset($actionMethods[$key]);
                      }
                  }
                  // Load the ApplicationController (if there is one)
                  App::import('Controller', 'AppController');
                  $parentActions = get_class_methods('AppController');
                  $controllers[$controller] = array_diff($actionMethods, $parentActions);
              }
          }
          return $controllers;
      }
  </code></pre>