Django、Rails 路由...点?
我是一名网络开发(和大学)的学生,所以如果这听起来很天真和冒犯,我很抱歉,我当然不是那个意思。 我的经验是使用 PHP 和即将到来的一个小型项目(一个美化的轮班日历),我希望学习一个更高级别的框架来减轻代码负担。 到目前为止,我研究了 CakePHP、Symfony Django 和 Rails。
使用 PHP,URL 可以非常简单地映射到文件,并且它“正常工作”。 对于服务器来说速度很快,而且很直观。 但对于所有这些框架,都倾向于通过使 URL 映射到不同的函数并将参数路由到不同文件中的不同变量来“美化”URL。
我正在阅读的《The Rails Way》一书承认这太慢了,并且是大型项目中大多数性能问题的原因。 我的问题是“为什么首先要有它?”? url-maps-to-a-file 范例(或 mod_rewrite 到单个文件)中是否有特定的点需要正则表达式和复杂的路由方案? 如果不使用它们,我是否会错过一些东西?
提前致谢!
I'm a student of web development (and college), so my apologies if this comes off sounding naive and offensive, I certainly don't mean it that way. My experience has been with PHP and with a smallish project on the horizon (a glorified shift calendar) I hoped to learn one of the higher level frameworks to ease the code burden. So far, I looked at CakePHP Symfony Django and Rails.
With PHP, the URLs mapped very simply to the files, and it "just worked". It was quick for the server, and intuitive. But with all of these frameworks, there is this inclination to "pretty up" the URLs by making them map to different functions and route the parameters to different variables in different files.
"The Rails Way" book that I'm reading admits that this is dog slow and is the cause of most performance pains on largish projects. My question is "why have it in the first place?"? Is there a specific point in the url-maps-to-a-file paradigm (or mod_rewrite to a single file) that necessitates regexes and complicated routing schemes? Am I missing out on something by not using them?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(6)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
mod_rewrite
这样的东西,这并不比 Rails 的 url 映射更容易。http://www.example.com/
用户名/
一些其他内容的 URL <代码>/。 这也可以使用mod_rewrite来实现,但至少对我来说,在django项目中配置url比在我运行应用程序的每个apache实例中配置url更容易。只是我的2分钱...
mod_rewrite
which isn't easier then Rails' url mappings.http://www.example.com/
username/
some additional stuff/
. This can be also made withmod_rewrite
, but at least for me it's easier to configure urls in django project then in every apache instance I run application at.just my 2 cents...