-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Router Regex not working with controllers #2330
Comments
First off - thanks for filling out such a thorough bug report. That is much appreciated! However, we recently revised the user guide to not show that anymore. Not only does it not work, it's not a good idea. See this issue for more details on why. It sounds like you're wanting the CI3 style of auto-routing based on controller/method. Good news is - that still works, you just have to make sure your namespacing is correct for the controllers in your |
Thank You very much for the explanation but I cannot make it work anyway.
if I want to make my app access controllers for Admin namespace it simply doesn't work. If I set properly controller in directory admin/Controllers it will throw 404 error and I have it in config autoload to include Admin namespace as well so I tried to do it this way. In this case, it is more like module I do not understand why the user shouldn't be able to access any controller in a given namespace if I want to have it like that. If it would be my primary namespace it would do it anyway like this. All the time user can access any controller and method if I am not mistaken. |
Just a thought,
|
nope, this is set properly :) According to user guide this is not possible now. Auto-discovery is only for Events, Registrars, Route files, Services and controllers ave to be specified all the time that doesn't make sense. This restriction I do not understand why is here. |
I understand you set a namespace of Admin\Auth in autoload and in the Controller you're using Admin\Controllers\Auth (which I guess will not be found). |
Describe the bug
The problem seems to be in the router. My code is like this doesn't work. Error 404.
According to the guide, it should be possible to pass the controller and method name from URL during this. I tried and it works to pass it as method argument and display it in the controller.
It works like this to redirect everything from /admin/* to some defined controller in another namesapce defined like below.
This doesn't worka as well. Error 404
Since it doesn't make log when accessing not existing controller. I am assuming it tries to pass segments as arguments to not defined controller all the time and can not pass it as controller name.
CodeIgniter 4 version
4.0.0 rc-2 - develop branch
Affected module(s)
Expected behaviour, and steps to reproduce if appropriate
With this code, I expect to pass the first segment after "admin" as controller name and second segment as the method with the defined namespace. This should work according to the user guide.
Context
The text was updated successfully, but these errors were encountered: