-
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
Route can not work: Controller or its method is not found #2299
Comments
If the first character of the "to" parameter is a dollar sign, as shown, then the first segment is not replaced at all. In the example reported, and with a test URI "/products/apple/222"
I can replicate the problem, but have been unable to solve it :( |
@lonnieezell Is the user guide correct, that the above route should work as descibed.I don't want to bang my head against the wall if this is a writeup issue. |
I think the docs definitely need to be changed to not show that example. It really doesn't make any sense and, if I wrote that, I apologize. :) While I think what you're trying to do there is technically possible, it's completely a bad idea. You should never let the URI specify the controller to run like that. Let auto-routing do it's magic, because if you start doing what that example shows, then a user can attempt to run any controller/method in the App\Controllers namespace. Especially when used with So, yes, that example needs to be changed! For a URI of
|
I read the code and guess the problem may happen because when parsing the url to the controller class, the code join the namespace and controller name like App\Controllers\$1::id_$2. Then the \$1 can not be a correct regular expression. Maybe we can first parse the regular expression $1::id_$2, then attached it with the namespace. |
When I add a route as the document described:
But it shows the error:
CodeIgniter 4 version
rc-2.1
Affected module(s)
Router
Context
Maybe Some regular expression replacement error occurred when match the uri.
The text was updated successfully, but these errors were encountered: