Display current application routes #1763

Closed
Ragazzo opened this Issue Jan 4, 2014 · 32 comments

Comments

Projects
None yet
7 participants
@Ragazzo
Contributor

Ragazzo commented Jan 4, 2014

I think it would be good to have console command and debug toolbar with routes that are defined in application. Similar to bundle exec rake routes and laravel routes.

  • php yii routes - display all routes variants (not only first match).
  • php yii routes posts - display all routes for given controller.
  • php yii routes posts/view - display all routes for given controller action.
@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Jan 4, 2014

Member

routes are not configured in console application so you can not show them.
What is the benefit of showing them in debug tool? Imo it is much better to view them in config.

Member

cebe commented Jan 4, 2014

routes are not configured in console application so you can not show them.
What is the benefit of showing them in debug tool? Imo it is much better to view them in config.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

Benefit is to not view them via config. I think we can parse web config to get rules, and controllers. This is very useful especially for REST api and other things when debugging. You also dont need to browse through all controllers to see what filters and hooks are applied.

Contributor

Ragazzo commented Jan 4, 2014

Benefit is to not view them via config. I think we can parse web config to get rules, and controllers. This is very useful especially for REST api and other things when debugging. You also dont need to browse through all controllers to see what filters and hooks are applied.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

This is not possible for Yii because each URL rule in Yii may correspond to multiple routes.

Member

qiangxue commented Jan 4, 2014

This is not possible for Yii because each URL rule in Yii may correspond to multiple routes.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

But we can parse them as url-manager do.

Contributor

Ragazzo commented Jan 4, 2014

But we can parse them as url-manager do.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

How? How do you parse this rule? '<controller>/<action>' => '<controller>/<action>'

Member

qiangxue commented Jan 4, 2014

How? How do you parse this rule? '<controller>/<action>' => '<controller>/<action>'

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

for each controller will display controller/action per each action, as it applied.

Contributor

Ragazzo commented Jan 4, 2014

for each controller will display controller/action per each action, as it applied.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

Well, this is not true in practice. If this rule is at the bottom, some controller/action may not match it.

Member

qiangxue commented Jan 4, 2014

Well, this is not true in practice. If this rule is at the bottom, some controller/action may not match it.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

True, but this is how application works. We should not display all routes, only those what be really applied, and used by application request, because other does not make sense (displaying all variants for route if already one was found).

Contributor

Ragazzo commented Jan 4, 2014

True, but this is how application works. We should not display all routes, only those what be really applied, and used by application request, because other does not make sense (displaying all variants for route if already one was found).

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

Assume we have the following two rules, what should be shown regarding the route post/view?

[
   '<controller>/<id:\d+>' => '<controller>/view',
   '<controller>/<action>' => '<controller>/<action>',
]
Member

qiangxue commented Jan 4, 2014

Assume we have the following two rules, what should be shown regarding the route post/view?

[
   '<controller>/<id:\d+>' => '<controller>/view',
   '<controller>/<action>' => '<controller>/<action>',
]
@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

post/{id}, or if table then - GET | post/{id} | "some filters here if needed"

Contributor

Ragazzo commented Jan 4, 2014

post/{id}, or if table then - GET | post/{id} | "some filters here if needed"

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

But in case when the user doesn't provide id parameter, the second rule should be applied.

Member

qiangxue commented Jan 4, 2014

But in case when the user doesn't provide id parameter, the second rule should be applied.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

And what if there's another rule '<controller>/<name:\w+>' => '<controller>/view' which is after the first rule?

Member

qiangxue commented Jan 4, 2014

And what if there's another rule '<controller>/<name:\w+>' => '<controller>/view' which is after the first rule?

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

But in case when the user doesn't provide id parameter, the second rule should be applied.

if there is no id, how he will call actionView($id) he will get exception.

And what if there's another rule '/name:w+' => '/view' which is after the first rule?

but he also will get exception with this route in request because of no id.

Anyway what i want is simple route=>rules matches console output, because it will simplify rules creating and will help developer in debug. In Yii1 creating and applying rules was a little bit painful.

Contributor

Ragazzo commented Jan 4, 2014

But in case when the user doesn't provide id parameter, the second rule should be applied.

if there is no id, how he will call actionView($id) he will get exception.

And what if there's another rule '/name:w+' => '/view' which is after the first rule?

but he also will get exception with this route in request because of no id.

Anyway what i want is simple route=>rules matches console output, because it will simplify rules creating and will help developer in debug. In Yii1 creating and applying rules was a little bit painful.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

No, he won't if he declares the action to be actionView($id = 0, $name = '').

Member

qiangxue commented Jan 4, 2014

No, he won't if he declares the action to be actionView($id = 0, $name = '').

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

right, in this way then we can display all routes that could match in the detail route info. For example:
php yii routes - display all routes only with first matches.
php yii routes post/view - displays route detailed info about all possible matches. Can be implemented as running matches, if found match then delete this match and run once again until all matches will be found.

This tool will indeed help developer.

Contributor

Ragazzo commented Jan 4, 2014

right, in this way then we can display all routes that could match in the detail route info. For example:
php yii routes - display all routes only with first matches.
php yii routes post/view - displays route detailed info about all possible matches. Can be implemented as running matches, if found match then delete this match and run once again until all matches will be found.

This tool will indeed help developer.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

What I want say is that yii routes doesn't make sense because you can't precisely determine the first matches without knowing the GET parameters. If you can't display precise information, then it's useless and harmful.

yii routes post/view makes some sense by displaying all possible matches.

Member

qiangxue commented Jan 4, 2014

What I want say is that yii routes doesn't make sense because you can't precisely determine the first matches without knowing the GET parameters. If you can't display precise information, then it's useless and harmful.

yii routes post/view makes some sense by displaying all possible matches.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

the first matches without knowing the GET parameters

hm, right. what if we then keep yii routes for REST? yii routes/rest here i think we already know all possible combinations.

yii routes post/view makes some sense by displaying all possible matches.

yes. Also if user is applying some route he will be searching by it and dont need all info about all routes.

Contributor

Ragazzo commented Jan 4, 2014

the first matches without knowing the GET parameters

hm, right. what if we then keep yii routes for REST? yii routes/rest here i think we already know all possible combinations.

yii routes post/view makes some sense by displaying all possible matches.

yes. Also if user is applying some route he will be searching by it and dont need all info about all routes.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

hm, right. what if we then keep yii routes for REST? yii routes/rest here i think we already know all possible combinations.

I don't quite understand it...

Member

qiangxue commented Jan 4, 2014

hm, right. what if we then keep yii routes for REST? yii routes/rest here i think we already know all possible combinations.

I don't quite understand it...

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

well when you will provide web-api support, there also will be rules for web-api, like DELETE, GET, POST, PATCH. and routes/rest will display this all routes. routes/rest posts will display all rest-routes for posts controller.

Contributor

Ragazzo commented Jan 4, 2014

well when you will provide web-api support, there also will be rules for web-api, like DELETE, GET, POST, PATCH. and routes/rest will display this all routes. routes/rest posts will display all rest-routes for posts controller.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

routes/rest: will it display GET routes?

Member

qiangxue commented Jan 4, 2014

routes/rest: will it display GET routes?

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

yes, similar to these. Also as you can see rake routes and laravel display all possible routes and not only first match, maybe we should also go these way.
php yii routes - display all routes variants (not only first match).
php yii routes posts - display all routes for given controller.
php yii routes posts/view - display all routes for given controller action.

Contributor

Ragazzo commented Jan 4, 2014

yes, similar to these. Also as you can see rake routes and laravel display all possible routes and not only first match, maybe we should also go these way.
php yii routes - display all routes variants (not only first match).
php yii routes posts - display all routes for given controller.
php yii routes posts/view - display all routes for given controller action.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

This makes more sense to me.

Member

qiangxue commented Jan 4, 2014

This makes more sense to me.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

Yes, sorry for confusing you about first match. The above implementation makes more sense indeed.

Contributor

Ragazzo commented Jan 4, 2014

Yes, sorry for confusing you about first match. The above implementation makes more sense indeed.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Jan 4, 2014

Member

No problem. Clarifying requirements is often not a simple task.

Member

qiangxue commented Jan 4, 2014

No problem. Clarifying requirements is often not a simple task.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

Thank you, should i add this examples in the description as to-do list? Will be easy then to see what we need to implement.

Contributor

Ragazzo commented Jan 4, 2014

Thank you, should i add this examples in the description as to-do list? Will be easy then to see what we need to implement.

@samdark

This comment has been minimized.

Show comment
Hide comment
@samdark

samdark Jan 4, 2014

Member

Yes, please do.

Member

samdark commented Jan 4, 2014

Yes, please do.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Jan 4, 2014

Contributor

Done.

Contributor

Ragazzo commented Jan 4, 2014

Done.

@Ragazzo Ragazzo referenced this issue Mar 30, 2014

Closed

URL Routing #2920

@qiangxue qiangxue added this to the 2.1 milestone Apr 16, 2014

@Ragazzo Ragazzo closed this Jun 27, 2014

@cebe cebe removed this from the 2.1 milestone Jul 23, 2014

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Sep 4, 2014

Contributor

looks like accidentally closed by me , reopening this one since it is not implemented as i see , if no feel free to close this one

Contributor

Ragazzo commented Sep 4, 2014

looks like accidentally closed by me , reopening this one since it is not implemented as i see , if no feel free to close this one

@NickvdMeij

This comment has been minimized.

Show comment
Hide comment
@NickvdMeij

NickvdMeij Sep 20, 2016

+1, this would be a perfect addition for those who would like to have it. Especially in large projects, the config file might be seperated in different config files which are merged together, making it hard to look up a specific route. Would love to see this feature implemented

+1, this would be a perfect addition for those who would like to have it. Especially in large projects, the config file might be seperated in different config files which are merged together, making it hard to look up a specific route. Would love to see this feature implemented

@dynasource

This comment has been minimized.

Show comment
Hide comment
@dynasource

dynasource Oct 29, 2016

Member

if somebody wants to have this in core, please feel free to do a PR. 3 years have passed with little progress so Im closing this one.

Member

dynasource commented Oct 29, 2016

if somebody wants to have this in core, please feel free to do a PR. 3 years have passed with little progress so Im closing this one.

@mjonas87

This comment has been minimized.

Show comment
Hide comment
@mjonas87

mjonas87 Mar 20, 2018

Routing in Yii is not intuitive. Having this in place would be a major boon and would help with diagnosing routing configuration issues. Coming to Yii from other frameworks, I was pretty shocked to find this basic feature missing.

He said without having time to commit to resolving the problem

mjonas87 commented Mar 20, 2018

Routing in Yii is not intuitive. Having this in place would be a major boon and would help with diagnosing routing configuration issues. Coming to Yii from other frameworks, I was pretty shocked to find this basic feature missing.

He said without having time to commit to resolving the problem

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo May 4, 2018

Contributor

4+ years and counting :D

Contributor

Ragazzo commented May 4, 2018

4+ years and counting :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment