Get list of controller in Codeigniter

 Example code to retrieve controller name

    public function spout_nonsense()

{ $string = shell_exec("ls application/controllers | paste -sd ',' -"); $controller_list = explode(',', $string); echo '<html><head></head><body><table><tbody>'; foreach ($controller_list as $file_name) { echo '<tr><td>'.str_replace('.php', '', $file_name).'</td></tr>'; } echo '</tbody></table></body></html>'; }

1. In order to retrieve all controller name, you can make a function that can construct list
2. The code given is for generate through server terminal.


- Credit : Firdaus Safari (firdausbsafari.blogspot.com)

Comments

Popular posts from this blog

Create Slack application

Tips testing local untuk programmer 📌