Can't make Dynamic Routes with Groups And Spacenames and Regex work - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Can't make Dynamic Routes with Groups And Spacenames and Regex work (/showthread.php?tid=73218) |
Can't make Dynamic Routes with Groups And Spacenames and Regex work - ci_user99 - 04-01-2019 Hi, I am having trouble defining my routes for my admin pages. I have multiple Controllers in my app/Admin folder with Namespace App\Admin (including Dashboard and Order) Here is an example Order.php : Code: <?php What I wanted to achieve was : Code: $routes->get('/', 'Home::index'); to get the default index function of my \App\Admin\Order controller. I did notice the $0, $1 ... syntax only works when there is at least one forward slash in front of my route "/([a-zA-Z_]+)" which I think is unfortunate. I can easily show the Dashboard (example.com/admin) that is hardcoded but can't seem to get the Order controller (example.com/admin/Order or even example.com/admin/order) through the regex, although they are in the same namespace and folder. It seems that you can use a lower case first letter when you want to get a controller through its filename, but when it comes to namespaces it's case sensitive or am I wrong? I also tried Code: $routes->get('/', 'Home::index'); but alas it doesn't work either. I was hoping to use the group feature so that I can easily add other routes through regex like : Code: $routes->get('([a-zA-Z_]+)/edit' , '$1::edit' ); or Code: $routes->get('([a-zA-Z_]+)/add' , '$1::add' ) which doesn't seem too farfetched. |