better auto routing for controllers inside folders - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: better auto routing for controllers inside folders (/showthread.php?tid=79952) |
better auto routing for controllers inside folders - ShinProg - 08-22-2021 Hello, I'm creating a standalone image manager module for my website. I have a controller class with 8 public methods (so, 8 pages that might share the same private helpers and constants), but even if there is currently one file, I want to organize every container modules into a folder : src/ ├───Controllers/ │ │ someFiles.php │ └───Img/ │ Img.php The URL to access to the "image foobar preview page" (which is the "view" method with the argument "foobar" inside the Controllers/Img/Img.php class) is localhost:8080/Img/Img/view/foobar. The URL is a bit big, so I want to change it to "localhost:8080/img/view/foobar" easily. What I tried so far and don't work :
Is there a way to achieve what I want, without making a route rule for every method inside the controller ? Here is the source code of my controller as of today (commit 2df0b2f) : https://github.com/Kagescan/code.kagescan.fr/blob/codeIgniter/App/Controllers/Img/Img.php Thanks in advance ! RE: better auto routing for controllers inside folders - wuuyun - 08-22-2021 [quote pid="389482" dateline="1629662131"] i think is difficult to solve . suggest create your own core router class https://codeigniter.com/user_guide/extending/core_classes.html#extending-core-classes [/quote] RE: better auto routing for controllers inside folders - InsiteFX - 08-23-2021 This might be what your looking for. CodeIgniter User Guide - Remapping Method Calls Read it carerfully. RE: better auto routing for controllers inside folders - ShinProg - 11-21-2021 Hmm that what I'm looking for, thanks you so much for the reply ! |