bug plugin name in url are not underscore#757
bug plugin name in url are not underscore#757bronze1man wants to merge 2 commits intocakephp:masterfrom
Conversation
|
The value for |
|
Also please don't include debugging comments/description in code patches. Your pull request cannot be merged in that case. |
|
Additionally the controller + action names are not automatically underscored. This would make plugin a special case, which I don't want. |
|
In my opinion controller and plugin names should be accepted as CamelCase and underscore. Two reasons why I think this:
I stumbled across this pull request while searching for solutions for this situation. Normally I would've let it be and just typed the names underscored, but this time I'm testing a 3rd party plugin that's called JSON_REST_Tools(working title), which is kind of horrible to write in underscore(j_s_o_n__r_e_s_t__tools). I think it would be neat if we could tap into the url forming and parsing methods and add our own underscore conversions in a way we see best. I for one wouldn't mind if there was an option to have all urls CamelCased. EDIT: |
|
You can provide custom inflections. Just create a subclass of CakeRoute and generate URL's as you need within the routes. |
|
I'll look into that. Thanks :) |
|
I think this should be treated, because as it works right now is not coherent. Also, thinking about how url works when used as an array, you put 'plugin' as key and the plugin NAME as value, the same with controllers, 'controller' key holds the controller NAME and so for actions. So, if the controller name is MyControllerName, why should I put my_controller_name when using it in urls? This is a bit confunsing, if I want to create a route to MyControllerName, and routing MUST be underscored, I don't see the reason why can't Router class handle this conversion. My proposal is that Router should convert pluing and controller names automatically to its underscored forms. Also, camel cased controller names in urls should not be supported, to avoid confusing. Router::url(array( |
|
One reason we have been avoiding adding more automagic is its impact on runtime performance. CakePHP has not historically been at the top of the benchmark charts. One large contributing factor to this has been automagic and trying to infer what the developer meant. Removing that inference allows the framework to perform better and allow us to field fewer questions when the inference goes wrong. |
|
Allowing access both ways needs to be manually handled by the dev right now to avoid multiple ways of accessing the url and/or SEO duplicate content. Must are probably not aware of that. Accessing those urls should all be via underscore only IMO. And if you try to access it differently, it should 404. At least in future versions of Cake (3.x then for example): This would unify the behavior in a clean way and would give feedback to the dev right away (wrong link/router calls). I agree that it should not automatically inflect as it would decrease performance. |
|
@dereuromark Agreed It would be great yo see that kind of change in Router for 3.0. I think a big part of the current problem is that things 'half' work right now. |
|
Ok, yep, I did not consider performance issues. I agree with @dereuromark, not to inflect automatically, but yes to have a unified behavior, this would avoid confusion besides to improve routing from a SEO point of view. This is off topic, but as markstory mentioned Router for 3.0, something that would be awesome to add to Router is the ability to define some kind of alias or unique identifier when you define a route, so then you can use it only for its identifier (and parameters) instead of the array (controller, action, etc). This could be great for developers (speed up coding and better control on routing), but also I think that could improve performace, avoiding the Framework having to detect the matched route and just getting it by its identifier. Btw, sorry for my english. |
|
Named (or aliased) route was already implemented in 3.0 @xavier83ar On Mon, Aug 12, 2013 at 2:09 PM, xavier83ar notifications@github.comwrote:
|
|
Cool!, I've not had time to check 3.0 yet. I'll give it a time soon to see what's new. Great work guys!. |
router::url(array('plugin'=>'FileUpload','controller'=>'FileUpload','action'=>'upload',)) return
/FileUpload/FileUpload/upload ,then cakephp will lookfor FileUpload controller FileUpload action