-
Notifications
You must be signed in to change notification settings - Fork 310
Bug in the router #99
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
Comments
This can be fixed by changing the Router's
(I will be incorporating these changes when I get chance) |
Great to now is okay, but if I want to add default parameter (language - en) I get the error: What I want to do. If you open site.com/controller/index - it doesn't work, I think this is a disadvantage because we have to create a lot of routers, for example:
So, what I make and no working. In the file Router.php in method match() I add
And this is not working and may be is not good practice.
Im student in the udemy EDIT: I have one more idea. In method add() we can add in preg_match for NEW default parameter. This is optional example: // Add the routes And preg_match check for the parameter is is have add the default language. |
That's one way to do it yes - if this works for you, then no problem. As for it matching with no language, it could be because of the
|
Nothing. After remove + in add parameter is not working. I take a wrong: 404 -> No route matched. What you think for this situation? |
Please can you let me know the full URL that you're using that doesn't match? |
http://localhost/en/posts/index - its okay
http://localhost/posts/index - its have error -> no route matched
I use for the debug print_r() in method match
|
To match the http://localhost/posts/index URL, you need a "catch-all" route at the end, after all the others have been defined:
Routes need to be added in order of the most specific first, then the least specific last. |
Hi everybody,
I found one bug in Router.php
The problem comes when I try to create the maximum length of the string I get. Then the curly brace is exchanged with the ordinary one.
So, If u input new data in index.php like;
$router->add('{lang:[a-z]{2}+}/{controller}/{action}');
$router->add('{lang:[a-z]{2}+}/{controller}/{action}/{id:\d+}');
You take this array:
This is wrong:
{2)+}
this is correct:
{2}+)
The problem comes when I try to create the maximum length of the string I get. Then the curly brace is exchanged with the ordinary one.
The text was updated successfully, but these errors were encountered: