Closed Yahasana closed 5 years ago
@mruz new implement for route done. do you have script to test it performance with other routers?
A good piece of work, thanks! I don't have, but we could use the ones form tests in the 1000 loop.
@Yahasana is it possible to have a static route the same as placeholder?
['GET', '/contact', ['controller' => 'index', 'action' => 'contact']],
['GET', '/{controller}', ['controller' => '[a-z]+[/]?']],
I tired with {action}
too, but it's not working.
please check comments in Router::setRoutes
L164
// the rule format: ['name' => ["httpMethod", "URI pattern", "regex", "defaults"]]
// there is no placeholder for static route, so regex is null
['GET', '/contact', null, ['controller' => 'index', 'action' => 'contact']]
It works, thanks. Is it a bug that
['GET', '/{action}', ['action' => '[aboutus|policy|terms|contact]+']],
matches /user
too?
nope, do you add other route rules?
['GET', '/{action}', ['action' => '[aboutus|policy|terms|contact]']],
Yes, /{controller}
as I sent before.
so /user
will match the rule
['GET', '/{controller}', ['controller' => '[a-z]+[/]?']],
Routes
['GET', '/{module}', ['module' => '[admin|doc]+']],
['GET', '/{action}', ['action' => '[aboutus|policy|terms|contact]+'], ['controller' => 'index']],
['GET', '/{controller}', ['controller' => '[a-z]+[/]?']],
Tests
['/contact', ['frontend', 'index', 'contact', []]],
['/admin', ['admin', 'index', 'index', []]],
['/user', ['frontend', 'user', 'index', []]],
Result
1) Tests\RoutesTest::testUniversalGET with data set #2 ('/user', array('frontend', 'user', 'index', array()))
/user
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
0 => 'frontend'
- 1 => 'user'
- 2 => 'index'
+ 1 => 'index'
+ 2 => 'user'
3 => Array ()
)
ok, it should be:
['GET', '/{module}', ['module' => 'admin|doc']],
['GET', '/{action}', ['action' => 'aboutus|policy|terms|contact']],
['GET', '/{controller}', ['controller' => '[a-z]+[/]?']],
thanks!
controller should NOT contain /
['GET', '/{controller}', ['controller' => '[a-z]+']],
['GET', '/{controller}[/]', ['controller' => '[a-z]+']],
make it faster, robust and full features.
one more thing: the old router was renamed to
FastRouter
. feel free to inject it intodi
by hand.