简体   繁体   English

Ruby on Rails或PHP框架

[英]Ruby on Rails or a PHP framework

I am a capable programmer and I write software for a living. 我是一个有能力的程序员,并且我以谋生为目的编写软件。 I am taking up a new project to build a website that has a bunch of forms that perform CRUD operations on a database and some multimedia. 我正在承担一个新项目,以建立一个网站,该网站具有许多在数据库和某些多媒体上执行CRUD操作的表格。 I am very familiar with PHP and Python and have written some websites in them. 我对PHP和Python非常熟悉,并在其中编写了一些网站。 I have written some rake tasks and a few ruby scripts that run in production, but I never wrote any websites in ruby. 我已经编写了一些rake任务和一些在生产环境中运行的ruby脚本,但是我从未用ruby编写任何网站。 I am considering using Rails, but I have the following questions. 我正在考虑使用Rails,但是我有以下问题。 It would be great to know the answers to any/all of these: 很高兴知道任何/所有这些答案:

  • The project should be done in a month and is very time sensitive. 该项目应在一个月内完成,并且对时间非常敏感。 Is 1 month enough for learning with and building a website in RoR? 1个月足够学习RoR并建立网站吗?
  • Writing direct SQL queries is one of my strengths and I would like to use it. 编写直接SQL查询是我的强项之一,我想使用它。 I heard that RoR is a pain to use if I am writing SQL queries directly. 我听说如果直接编写SQL查询,那么使用RoR会很痛苦。 Is this true? 这是真的? Or can I just say execute a query, give me the results (as a list or dictionary) and then I will tell you how to render them? 或者我可以说执行查询,将结果(作为列表或字典)给我,然后告诉您如何呈现它们?
  • I have heard that RoR does joins in memory and doesn't use the facilities offered by the database. 我听说RoR确实加入了内存,并且没有使用数据库提供的功能。 Is this correct? 它是否正确?
  • I need to create a website that displays a lot of Images, videos and Java applets. 我需要创建一个显示很多图像,视频和Java小程序的网站。 Would RoR hinder my ability to do this? RoR会阻碍我这样做的能力吗?
  • I am OK using a PHP framework. 我可以使用PHP框架。 Is this a bad idea? 这是一个坏主意吗? If not, which PHP framework is closest to Rails in terms of programming convenience. 如果不是,那么就编程方便性而言,哪个PHP框架最接近Rails。

Answering your questions in order: 按顺序回答您的问题:

  1. You could certainly learn Rails in that time. 您当然可以在那时学习Rails。 It's enough time to build a Web site too, but whether it's enough time for you to build your Web site is a different question. 这是足够的时间来建立一个网站太多,但它是否有足够的时间为打造您的网站是一个不同的问题。 I would personally not want to try such a thing on a tight deadline. 我个人不想在紧迫的期限内尝试这种事情。
  2. You can write your own SQL queries, but there's little point to using Rails if you are going to work around all of its features. 可以编写自己的SQL查询,但是如果要使用Rails的所有功能,那么毫无用处。
  3. Joins are normally done as part of the database queries generated by ActiveRecord. 连接通常是由ActiveRecord生成的数据库查询的一部分。
  4. Using ROR is pretty much orthogonal to having images, videos, etc. on a page. 使用ROR与在页面上放置图像,视频等几乎是正交的。
  5. I haven't used it, but CakePHP aims to be quite Railsy. 我没有使用过它,但是CakePHP的目标是变得相当Railsy。 Zend and CodeIgniter are more popular and I'm told better by people who have used all three, though. Zend和CodeIgniter更受欢迎,但是使用这三种方法的人告诉我的更好。

The project should be done in a month and is very time sensitive. 该项目应在一个月内完成,并且对时间非常敏感。 Is 1 month enough for learning with and building a website in RoR? 1个月足够学习RoR并建立网站吗?

Given the experience you describe I imagine one month to learn and build a simple-ish app (especially if it is CRUD based) should be enough. 鉴于您所描述的经验,我想一个月学习和构建一个简单的应用程序(尤其是基于CRUD的应用程序)就足够了。 If there is a significant level of complexity I would be loath to learn a new technology and deliver a complicated site in one month. 如果存在很大的复杂性,我将不愿意学习一种新技术并在一个月内交付一个复杂的站点。

Writing direct SQL queries is one of my strengths and I would like to use it. 编写直接SQL查询是我的强项之一,我想使用它。 I heard that RoR is a pain to use if I am writing SQL queries directly. 我听说如果直接编写SQL查询,那么使用RoR会很痛苦。 Is this true? 这是真的? Or can I just say execute a query, give me the results (as a list or dictionary) and then I will tell you how to render them? 或者我可以说执行查询,将结果(作为列表或字典)给我,然后告诉您如何呈现它们?

The rails way is to use the ActiveRecord object mapppings it gives you (and mostly these work very well) It is also very easy to write direct SQL if that is what you want to do Rails的方法是使用它为您提供的ActiveRecord对象映射(并且大多数情况下都运行良好),如果您要这样做,编写直接SQL也非常容易

ModelName.find_by_sql('your query')

is how you do that 你是怎么做到的

I have heard that RoR does joins in memory and doesn't use the facilities offered by the database. 我听说RoR确实加入了内存,并且没有使用数据库提供的功能。 Is this correct? 它是否正确?

ActiveRecord does a lot for you, but wherever performance is an issue, as above you can write your own SQL to leverage the advantages of the database. ActiveRecord对您有很多帮助,但是无论性能如何,如上所述,您都可以编写自己的SQL以利用数据库的优势。

I need to create a website that displays a lot of Images, videos and Java applets. 我需要创建一个显示很多图像,视频和Java小程序的网站。 Would RoR hinder my ability to do this? RoR会阻碍我这样做的能力吗?

I don't see why it should. 我不明白为什么要这样。 There are lots of gems and plugins out there which help with this sort of functionality, so it may well be the case that a lot of code could already be written for you. 有很多宝石和插件可以帮助您实现此类功能,因此很可能已经为您编写了许多代码。

I am OK using a PHP framework. 我可以使用PHP框架。 Is this a bad idea? 这是一个坏主意吗? If not, which PHP framework is closest to Rails in terms of programming convenience. 如果不是,那么就编程方便性而言,哪个PHP框架最接近Rails。

I'll let a PHP expert answer this bit. 我会让PHP专家回答这一点。

  • The project should be done in a month and is very time sensitive. 该项目应在一个月内完成,并且对时间非常敏感。 Is 1 month enough for learning with and building a website in RoR? 1个月足够学习RoR并建立网站吗?

If it's time-sensitive, stick with what you know.. That said, Rails has lots of plugins to handle things like image-uploads which may save you a lot of time. 如果它对时间敏感,请坚持使用您所知道的。.也就是说,Rails有很多插件可以处理诸如图像上传之类的事情,这可以节省您很多时间。 Rails has "scaffold generators" which create basic CRUD applications in a single command: Rails具有“脚手架生成器”,可在一个命令中创建基本的CRUD应用程序:

./script/generate scaffold title:text description:text when:datetime

..will generate the controllers/views to create/edit/delete items. ..将生成控制器/视图以创建/编辑/删除项目。 You can then easily wrap nicer looking HTML around it, add authentication (via restful_authentication ), and you may have your completed application in a few hours.. 然后,您可以轻松地在其周围包装漂亮的HTML,添加身份验证(通过restful_authentication ),然后可能在几个小时内就完成了应用程序。

  • Writing direct SQL queries is one of my strengths and I would like to use it. 编写直接SQL查询是我的强项之一,我想使用它。 I heard that RoR is a pain to use if I am writing SQL queries directly. 我听说如果直接编写SQL查询,那么使用RoR会很痛苦。 Is this true? 这是真的? Or can I just say execute a query, give me the results (as a list or dictionary) and then I will tell you how to render them? 或者我可以说执行查询,将结果(作为列表或字典)给我,然后告诉您如何呈现它们?

There's very few situation where you'd need to write SQL with ActiveRecord, but you can. 在极少数情况下,您需要使用ActiveRecord编写SQL,但是可以。 RoR is still Ruby code, so you can always use a MySQL library and do away with ActiveRecord if you really need to write raw SQL (but, again, you almost certainly don't) RoR仍然是Ruby代码,因此,如果您确实需要编写原始SQL,则始终可以使用MySQL库并取消ActiveRecord(但是,再次肯定,您不必这样做)

  • I have heard that RoR does joins in memory and doesn't use the facilities offered by the database. 我听说RoR确实加入了内存,并且没有使用数据库提供的功能。 Is this correct? 它是否正确?

There's no reason ActiveRecord cannot perform JOIN's via SQL queries, the ActiveRecord::Associations::ClassMethods mentions associations being performed via JOIN's. 没有理由说ActiveRecord无法通过SQL查询执行JOIN, ActiveRecord :: Associations :: ClassMethods提到通过JOIN执行的关联。

Besides, even if it does do JOINs through memory, it's worked perfectly well for however long Rails has been around.. 此外,即使它确实通过内存进行JOIN,但无论Rails已经存在了很长时间,它都可以很好地工作。

  • I need to create a website that displays a lot of Images, videos and Java applets. 我需要创建一个显示很多图像,视频和Java小程序的网站。 Would RoR hinder my ability to do this? RoR会阻碍我这样做的能力吗?

No. They're all just bits of HTML, which Rails can output as easily as any other framework. 不。它们全都是HTML的一部分,Rails可以像其他任何框架一样轻松地输出它们。

  • I am OK using a PHP framework. 我可以使用PHP框架。 Is this a bad idea? 这是一个坏主意吗? If not, which PHP framework is closest to Rails in terms of programming convenience. 如果不是,那么就编程方便性而言,哪个PHP框架最接近Rails。

Absolutely. 绝对。 If you don't go with Rails, use a PHP framework! 如果您不使用Rails,请使用PHP框架!

I would recommend against choosing a framework based on "how close to Rails" it is. 我建议不要选择基于“与Rails的距离”的框架。 PHP isn't Ruby. PHP不是Ruby。 Trying to "port" (in a manner) a framework to a different language rarely works as well as writing a framework for that language. 试图“端口”(的方式),以不同语言的框架很少奏效,以及编写该语言框架。

As I commented on Chuck's answer, "CodeIgniter and Zend are good PHP web-frameworks. CakePHP is a good Ruby on Rails imitation".. 当我评论Chuck的答案时,“ CodeIgniter和Zend是很好的PHP Web框架。CakePHP是很好的Ruby on Rails模仿”。

I found CodeIgniter felt much more like PHP (in a good way), it's documentation is also my favourite of any project I've used! 我发现CodeIgniter感觉更像PHP(以一种很好的方式),它的文档也是我使用过的任何项目的最爱!

The Zend Framework is very modular, you can drop bits of Zend into an existing PHP app, or use it's MVC routing system. Zend框架是非常模块化的,您可以将Zend的一部分放到现有的PHP应用程序中,或使用它的MVC路由系统。

CakePHP seems to be trying to make PHP act like Ruby, rather than making a framework that fits nicely with PHP. CakePHP似乎正在尝试使PHP像Ruby那样运行,而不是构建一个非常适合PHP的框架。


All that said, the reason you use Ruby on Rails is the community (and thus all the plugins and stuff that revolve around it). 综上所述,您使用Ruby on Rails的原因是社区(以及围绕它而来的所有插件和东西)。

For example, paperclip plugin makes it extremely easy to an image-upload form (along with thumbnailing). 例如, 回形针插件使图像上载表单(以及缩略图)变得非常容易。 To use it you add (to your model): 要使用它,您要添加(到模型中):

has_attached_file :photo, :styles => {:thumb=> "100x100#", :small  => "150x150>" }

Then in your view, where you want the upload form to be, add: 然后在您想要的上传表单所在的视图中,添加:

<% form_for :user, :html => { :multipart => true } do |f| %>
  <%= f.file_field :photo%>
<% end %>

That's it. 而已。


What I would recommend is spend a day making something simple in Rails. 我建议花一天的时间在Rails中简化一些事情。 There's countless great tutorials ( Railscasts are a good, random, example) and plenty of books on it. 有无数很棒的教程( Railscasts是一个很好的,随机的例子),并且有很多书籍。 See if you like it, if not try CodeIgniter, Zend or CakePHP (or Django, or Merb, or.... Just don't spend the whole month trying frameworks!) 看看是否喜欢它,如果不尝试CodeIgniter,Zend或CakePHP(或Django,Merb或...。。。。

拥有一些Python经验之后,您可以看看Django吗?

Rails is great for CRUD stuff. Rails非常适合CRUD。

1 - If you're already familiar with Ruby and MVC, a month should be fine. 1-如果您已经熟悉Ruby和MVC,那么一个月就可以了。 If not, there's a lot to learn. 如果没有的话,还有很多东西要学。

2 - Rails will let you execute SQL queries, but it's really set up to take advantage of ActiveRecord. 2-Rails可以让您执行SQL查询,但实际上是为了利用ActiveRecord而设置的。

3 - Rails is designed to switch between database types, so ActiveRecord does a lot on its own. 3-Rails旨在在数据库类型之间切换,因此ActiveRecord会自己做很多事情。 Look into ActiveRecord Associations for more info. 查看ActiveRecord关联以获取更多信息。

4 - Never tried Java applets, but the rest work fine. 4-从未尝试过Java applet,但是其余的都可以正常工作。

5 - If you're more comfortable with a PHP framework it's not a bad idea at all. 5-如果您对PHP框架比较满意,那么这并不是一个坏主意。 There are even a few that try to replicate a lot of Rails features, such as CodeIgniter. 甚至有少数尝试复制许多Rails功能,例如CodeIgniter。

Check out RailsGuides for a better idea about all this. 查看RailsGuides ,以获取有关所有这些的更好的主意。

I am OK using a PHP framework. 我可以使用PHP框架。 Is this a bad idea? 这是一个坏主意吗? If not, which PHP framework is closest to Rails in terms of programming convenience. 如果不是,那么就编程方便性而言,哪个PHP框架最接近Rails。

I guess CakePHP is close to RoR for a PHP framework. 我猜CakePHP对于PHP框架来说接近RoR。

I have not tried Rails myself, but wonder if it is a convenience. 我自己没有尝试过Rails,但是想知道这是否方便。 As far as Ive read (like the guy who spent 2 years making Rails do something it should not) when you need to do something more complex you apparently have to fight and hack the framework. 据Ive所读(就像花了2年时间让Rails做某事的人一样),当您需要做更复杂的事情时,您显然必须与框架打架。

There are other frameworks for Ruby, PHP and Python. 还有其他用于Ruby,PHP和Python的框架。 I suggest you look around a bit more before you decide. 我建议您在决定之前先四处看看。

If you want to code in PHP you could try Symfony with Zend Framework. 如果您想用PHP编写代码,则可以尝试使用Zend Framework的Symfony。

The project should be done in a month and is very time sensitive. 该项目应在一个月内完成,并且对时间非常敏感。 Is 1 month enough for learning with and building a website in RoR? 1个月足够学习RoR并建立网站吗?

It could be, but it could also make things unnecessarily harder on you. 可能是,但也可能使您不必要地感到困难。 I usually wait for a project with a relaxed timeline to try and learn a new technology. 我通常会等待时间表轻松的项目来尝试和学习新技术。 If time is of the essense, bust out your favorite language and get it done. 如果时间很紧迫,请用尽自己喜欢的语言并完成。

Writing direct SQL queries is one of my strengths and I would like to use it. 编写直接SQL查询是我的强项之一,我想使用它。 I heard that RoR is a pain to use if I am writing SQL queries directly. 我听说如果直接编写SQL查询,那么使用RoR会很痛苦。 Is this true? 这是真的? Or can I just say execute a query, give me the results (as a list or dictionary) and then I will tell you how to render them? 或者我可以说执行查询,将结果(作为列表或字典)给我,然后告诉您如何呈现它们?

I am not a Rails developer, but I do know it uses ActiveRecord. 我不是Rails开发人员,但我知道它使用ActiveRecord。 I am sure, however, that there is also a way to make it execute raw queries as most ORM do. 但是,我敢肯定,还有一种方法可以使它像大多数ORM一样执行原始查询。 Right there however you're going against the grain of what the framework wants you do and you may run into problems. 但是,在那里,您会遇到框架要执行的操作的粗俗之处,并且可能会遇到问题。

I have heard that RoR does joins in memory and doesn't use the facilities offered by the database. 我听说RoR确实加入了内存,并且没有使用数据库提供的功能。 Is this correct? 它是否正确?

Anything that abstracts out things for you, particularly database relationships, is going to be far from efficient. 任何为您抽象化的东西,尤其是数据库关系,都将远非高效。 Worrying about it beforehand is usually not necessary, and once your application is finished it is common practice to then identify any particular slow queries and redo them by hand if necessary. 通常不必事先担心它,一旦您的应用程序完成,通常的做法是识别任何特定的慢查询并在必要时手动重做。

I need to create a website that displays a lot of Images, videos and Java applets. 我需要创建一个显示很多图像,视频和Java小程序的网站。 Would RoR hinder my ability to do this? RoR会阻碍我这样做的能力吗?

I have no idea why it would. 我不知道为什么会这样。

I am OK using a PHP framework. 我可以使用PHP框架。 Is this a bad idea? 这是一个坏主意吗? If not, which PHP framework is closest to Rails in terms of programming convenience. 如果不是,那么就编程方便性而言,哪个PHP框架最接近Rails。

CakePHP is by far the closest framework to RoR. CakePHP是迄今为止最接近RoR的框架。 It borrows from a lot of its ideas. 它借鉴了很多想法。 I have used it with some success in the past. 过去,我已经成功地使用了它。 CodeIgniter , while not related to Rails, is also terrific if you want something lightweight that won't force you to do anything its way. CodeIgniter虽然与Rails不相关,但如果您想要轻量级的东西而又不会强迫您做任何事情,那么它也很棒。

http://www.doctrine-project.org/ http://www.doctrine-project.org/

I've had great success with the doctrine ORM : if you are writing object oriented php then this does the object->database record mapping for you. 我在ORM学说方面取得了巨大的成功:如果您正在编写面向对象的php,那么这将为您完成object-> database记录映射。 AFAIK this is one of the plusses to the django / rails framework. AFAIK这是django / rails框架的优点之一。

So this links up the oop/database functionality like this: 因此,这链接了oop /数据库功能,如下所示:

$foo = new User(); // makes a new 'transitory' user object
$foo->name = 'bob'; // works like you'd expect
$foo->save(); // but this pushes it into the database.
  //(There's a 'name' column in the 'User' table already: set up when Doctrine initializes).

& if you want a framework, it's a part of symfony now. &如果您想要一个框架,那么它现在就是symfony的一部分。


It's very motivating to have a real project to learn a new technology or approach, but it is possible to take on too much. 拥有一个真正的项目来学习一种新技术或新方法非常有动力,但是可能会承担太多的责任。 It'll take 5 times longer than you'd take in the technology you know. 它所花费的时间将比您所知道的技术要长5倍。 Which can be okay - the learning, and the results might be worth it. 没关系-学习和结果可能值得。 But doesn't sound like this is appropriate here. 但这听起来不适合这里。

Rails is a great framework, but learning that framework and becoming more familiar with constructs specific to Ruby might be a bit much to do simultaneously with a one month deadline. Rails是一个很好的框架,但是要学习该框架并更加熟悉Ruby特定的构造,可能需要一个月的期限才能同时完成。

To step into a web application framework, I would recommend using a PHP framework if you are already familiar with PHP. 要进入Web应用程序框架,如果您已经熟悉PHP,我建议您使用PHP框架。 While not a port, CakePHP is very much similar to Rails. 虽然不是端口,但CakePHP与Rails非常相似。 It is modeled after Rails, and is my favorite PHP framework. 它以Rails建模,是我最喜欢的PHP框架。 symfony is a solid framework, but if you're looking for something more Rails-esque I recommend you try CakePHP. symfony是一个可靠的框架,但是如果您正在寻找更多的Rails风格,我建议您尝试CakePHP。

If you're not already married to using Rails or something like it, I would recommend the Zend Framework. 如果您还不习惯使用Rails或类似工具,我建议您使用Zend Framework。 It is by far the most comprehensive web application framework available for PHP. 它是迄今为止可用于PHP的最全面的Web应用程序框架。

All of these frameworks will allow you to do all of the things you mentioned. 所有这些框架都将使您能够完成您提到的所有事情。 It might be easier to think of them as a select group of building blocks than a comprehensive operating system for your website that you extend with plug-ins. 与使用插件扩展的网站综合操作系统相比,将它们视为一组选定的构建基块可能更容易。 That would be more similar to a CMS like ExpressionEngine. 这将更类似于像ExpressionEngine这样的CMS。 You can do anything with these frameworks, they're simply code bases for you to draw from to make developing web applications less tedious. 您可以使用这些框架做任何事情,它们只是您可以借鉴的代码库,从而使开发Web应用程序变得不那么繁琐。

The Akelos framework is a PHP framework that purports being a port of Rails, so you might also be interested in that. Akelos框架是一个PHP框架,据称是Rails的移植版,因此您可能对此也很感兴趣。

As for writing SQL queries, it's possible with any PHP framework, but the idea behind these frameworks is convention over configuration. 至于编写SQL查询,可以使用任何PHP框架,但是这些框架背后的思想是约定而不是配置。 Each has its own ORM scheme to abstract SQL queries away from the developers. 每个人都有其自己的ORM方案,以使SQL查询脱离开发人员。 While this might be due to the fact that many web developers, at least in my experience, are terrified of SQL, as someone who also likes writing SQL, I do appreciate the massive amounts of time that an ORM framework can save. 尽管这可能是由于许多Web开发人员(至少以我的经验)对SQL感到恐惧,但作为一个也喜欢编写SQL的人,我确实感谢ORM框架可以节省大量时间。 Again, when the application is developed it's pretty much standard practice to profile the ORM's performance and look for areas to improve. 同样,在开发应用程序时,几乎是标准的惯例,以描述ORM的性能并寻找需要改进的地方。 Rapid-prototyping is a huge part of web application frameworks, so tools like this might actually be a hindrance to you. 快速原型制作是Web应用程序框架的重要组成部分,因此这样的工具实际上可能对您构成障碍。 Like others have said, using one of these frameworks might end up being pointless if you're just going to work around their facilities. 就像其他人说的那样,如果您只是围绕它们的设施工作,那么使用这些框架之一可能最终毫无意义。

Should you decide not to use one of these, PHP has a plethora of mature projects that will help you build an application, but seeking these out and learning how to implement them may take a great deal longer than learning a framework. 如果您决定不使用其中之一,PHP会提供许多成熟的项目来帮助您构建应用程序,但是要找到这些项目并学习如何实现它们,可能比学习框架要花费更长的时间。

IMO a month is very tight to learn and launch in a month ( I'm assuming you're not full time though ) and you wouldn't be full time if you're learning as well. IMO一个月的学习和发布工作非常紧张(我假设您还不是全职的),并且如果您也正在学习,则不会是全职的。 You know how it is when you get deeper. 当您更深入时,您会知道情况如何。

About a month ago I faced the same dilemma between RoR and MVC. 大约一个月前,我在RoR和MVC之间面临着同样的困境。 After a few weeks (learning at night ) I learned enough about RoR framework but ruby language was very new to me, the client wanted delivery and I was still in the "playground/sandbox" phase 几个星期后(晚上学习),我对RoR框架有了足够的了解,但是红宝石语言对我来说还是很新的,客户想要交付,而我仍处于“游乐场/沙盒”阶段

So, because I know c# and the .net framework well and I can find resources quickly I have since open for MVC and within 2 weeks I've delivered something to the client. 因此,因为我非常了解c#和.net框架,并且可以快速找到自MVC开放以来的资源,所以在两周之内就已经向客户端交付了一些东西。

So in my experience, learn RoR give it a week. 因此,以我的经验,学习RoR给它一个星期。 If you're finding it takes more than say 40 hours to get going with the actual application, then stick with PHP and do RoR when you have more time and less time restraints. 如果您发现要花费超过40个小时才能使用实际的应用程序,那么请坚持使用PHP并在有更多时间和更少时间限制的情况下执行RoR。

Goodluck either way though!! 不管怎样,好运!

If you're comfortable with Model View Controller stucture then Ruby on Rails isn't too hard to learn. 如果您对Model View Controller的结构感到满意,那么Ruby on Rails并不是很难学习。 I myself came from PHP's Zend Framework to Ruby on Rails and really found it a relief. 我本人是从PHP的Zend Framework迁移到Ruby on Rails的,并真的感到宽慰。 I like the whole idea of convention over configuration that Rails uses. 我喜欢Rails使用的约定之上的整个配置思想。 It keeps your application (and all future applications) well structured, which in my option is extremely important and time saving. 它使您的应用程序(以及所有将来的应用程序)保持良好的结构,在我看来,这非常重要且节省时间。

At this time I've been programming in Ruby with Rails for maybe about 6-7 months and I'm really enjoying it. 目前,我已经在Rails中使用Ruby编程大约6-7个月了,我真的很喜欢它。 Clean code, VERY fast development, it's really incredible. 干净的代码,非常快速的开发,这真是不可思议。 Especially with the generator files and database migrations. 尤其是在生成器文件和数据库迁移中。

As for RoR being a pain when writing raw queries, I'm not sure, I never even have to write them but you sure can with a simple method. 至于RoR在编写原始查询时的痛苦,我不确定,我什至不必编写它们,但是您肯定可以使用一种简单的方法。 That shouldn't be a problem. 那不应该是问题。

Once I started developing web applications in Ruby on Rails, I did not want to go back to PHP. 一旦开始使用Ruby on Rails开发Web应用程序,我就不想回到PHP。 Purely because I'm pretty much in love with how Rails works, the conventions, rapid development, clean code, consistent structure etc etc etc. But these days I now and then still get asked by clients to develop a web application with PHP. 纯粹是因为我非常喜欢Rails的工作方式,约定,快速开发,干净的代码,一致的结构等,但是这些天来,我仍然时不时地受到客户的要求,用PHP开发Web应用程序。 But in my eyes, if I went back in to Zend Framework I'd probably really get stressed as I find it extremely inefficient. 但是在我看来,如果我回到Zend Framework,我可能会感到非常压力,因为我发现它效率极低。 (That might be my own fault, I'm not sure, but in my eyes, compared to Rails, meh). (我不确定这可能是我自己的错,但与Rails相比,在我看来)。 I discovered the PHP Framework "CakePHP". 我发现了PHP框架“ CakePHP”。 This framework is as far as I know the closest thing to Rails and I currently use it to develop PHP applications. 据我所知,这个框架最接近Rails,目前我使用它来开发PHP应用程序。 It's pretty straightforward and works great. 它非常简单,效果很好。 It also has a VERY nice thing called the "cookbook" on their website which helps you get up and running very quickly. 在他们的网站上也有一个非常好的东西,叫做“ cookbook”,它可以帮助您快速启动和运行。 So if you were to choose a PHP framework I would personally go with CakePHP just because its the closest thing to Rails. 因此,如果您选择一个PHP框架,我个人会选择CakePHP,因为它与Rails最接近。

The only thing I myself am a little annoyed about with Rails is that it requires a certain version of Rails to be installed, and that version must be compatible with a specific version of Ruby. 我自己对Rails有点恼火的是,它需要安装特定版本的Rails,并且该版本必须与特定版本的Ruby兼容。 You'll need to get the hang of Gems, Plugins (which aren't hard to understand, to be honest). 您需要掌握Gems,插件(老实说,这并不难理解)。 But along with deployment, if you're running Apache 2+ then you need Passenger. 但是随着部署,如果您正在运行Apache 2+,那么您需要“乘客”。 Also to be safe you will want to freeze your gems and that kind of stuff to avoid conflicts with the servers specifications and installed utilities. 另外,为了安全起见,您将需要冻结宝石和类似的东西,以避免与服务器规格和已安装的实用程序发生冲突。

There's a lot more to learn than just the language and the framework when it comes to Ruby on Rails. 在Ruby on Rails上,不仅要学习语言和框架,还有很多东西要学习。 PHP is pretty simple, just upload and it works. PHP非常简单,只需上传即可使用。 So you might want to look in to that as well before developing the application. 因此,在开发应用程序之前,您可能还需要研究一下。

I think Rails is great, and it would be my first choice for such a project, but if you are in fact under a tight deadline and you are starting from square one with Rails, just don't do it. 我认为Rails很棒,这将是我进行此类项目的首选,但是如果您实际上在紧迫的期限内,并且从Rails的第一手开始,那就不要这样做。 Go with what you know. 跟着你所知道的去。 PHP might not be the greatest, but it's a very serviceable language. PHP可能不是最出色的,但是它是一种非常有用的语言。

Despite what people might say, Rails does have a non-trivial learning curve, especially if you are not familiar with MVC. 尽管人们可能会说些什么,但是Rails确实具有不平凡的学习曲线,尤其是在您不熟悉MVC的情况下。 There's definitely a "Rails Way" to do things, and coming from most other frameworks, it takes a while to grok. 肯定有一种“ Rails Way”来做事,并且来自大多数其他框架,这需要一段时间才能解决。

I think if you try to rush and learn Rails, you're just going to get frustrated, and I'm afraid this would taint your impression of it. 我认为,如果您尝试着急于学习Rails,将会感到沮丧,而且恐怕这会破坏您对此的印象。 Instead, try learning it in your spare time, or on a project with a more relaxed timeline. 相反,请尝试在业余时间或在时间表更宽松的项目中学习它。 I think you'll get a lot more out of it this way. 我认为您将通过这种方式获得更多收益。

Is 1 month enough for learning with and building a website in RoR? 1个月足够学习RoR并建立网站吗?

Yes. 是。

Writing direct SQL queries is one of my strengths and I would like to use it. 编写直接SQL查询是我的强项之一,我想使用它。 I heard that RoR is a pain to use if I am writing SQL queries directly. 我听说如果直接编写SQL查询,那么使用RoR会很痛苦。 Is this true? 这是真的? Or can I just say execute a query, give me the results (as a list or dictionary) and then I will tell you how to render them? 或者我可以说执行查询,将结果(作为列表或字典)给我,然后告诉您如何呈现它们?

Writing raw sql with Rails is not any more difficult than doing it with PHP. 用Rails编写原始sql并不比用PHP编写困难。 The object returned will be a hash of column-name/value pairs. 返回的对象将是列名/值对的哈希。 The only problem may come if you decide to start using ActiveRecord which returns an ActiveRecord object (not a plain hash) 如果您决定开始使用ActiveRecord并返回ActiveRecord对象(不是普通哈希),则可能会出现唯一的问题

I have heard that RoR does joins in memory and doesn't use the facilities offered by the database. 我听说RoR确实加入了内存,并且没有使用数据库提供的功能。 Is this correct? 它是否正确?

If you use raw sql, Rails shouldn't interfere with it. 如果您使用原始sql,Rails不应对此进行干预。

I need to create a website that displays a lot of Images, videos and Java applets. 我需要创建一个显示很多图像,视频和Java小程序的网站。 Would RoR hinder my ability to do this? RoR会阻碍我这样做的能力吗?

No. 没有。

I am OK using a PHP framework. 我可以使用PHP框架。 Is this a bad idea? 这是一个坏主意吗? If not, which PHP framework is closest to Rails in terms of programming convenience. 如果不是,那么就编程方便性而言,哪个PHP框架最接近Rails。

IDK. IDK。

I really like using ActiveRecord, but if you prefer raw sql, Rails can still be worth using. 我真的很喜欢使用ActiveRecord,但是如果您喜欢原始sql,Rails仍然值得使用。 You'll get good url handling, a lot of built-in security, nice MVC architecture, and a nifty templating system, all while writing Ruby, which for many, has been a good experience. 在编写Ruby的同时,您将获得良好的url处理,大量的内置安全性,良好的MVC架构以及漂亮的模板系统,对于许多人来说,这是一个很好的经验。

Nice thread - some great comments in here everyone. 不错的话题-每个人在这里都有很好的评论。 This has been useful to me. 这对我很有用。

I think adding the complexity of rewriting what you already know in a month - on a time sensitive project is a bad idea. 我认为在一个时间敏感的项目上增加重写一个月内您已经知道的内容的复杂性是一个坏主意。 Using any framework/tools you are unfamiliar with is probably a bad choice on any "time sensitive" project. 对于任何“时间敏感”项目,使用您不熟悉的任何框架/工具可能都是错误的选择。

That being said the Zend_Framework for php is pretty solid with its form abstractions. 话虽这么说, Zend_Framework for php的形式抽象非常扎实。 I found an easier time moving to ZF than RoR - I tried both at the same time. 我发现迁移到ZF的时间比RoR更容易-我同时尝试了两种方法。

The documentation for ZF is fair - reading the actual code of the library is still my best source for documentation though. ZF的文档很不错-尽管阅读库的实际代码仍然是我最好的文档来源。 It isn't that tough to learn or start up - and if you don't mind IRC / stackoverflowing questions you should be able to learn it pretty fast. 学习或启动并不难-如果您不介意IRC / stackoverflow问题,那么您应该可以很快地学习它。

Don't board the Rails train just because it looks cool. 不要仅仅因为看起来很酷就登上Rails火车。 I know it's what everyone is talking about these days but to be honest, it's really not that special and you'd be better off using a framework written in a language you are comfortable with. 我知道这是当今所有人都在谈论的话题,但老实说,这并不是那么特别,您最好使用以自己喜欢的语言编写的框架。 If you are really good at SQL then it would take longer to learn how to use ActiveRecord than to just write the queries by hand, and ActiveRecord is basically half of Rails, which kind of defeats the purpose of using the framework. 如果您真的很精通SQL,那么学习如何使用ActiveRecord的时间将比只手工编写查询的时间还要长,并且ActiveRecord本质上是Rails的一半,这与使用框架的目的相违背。 So based on the background info you provided, I'd say go with a PHP framework like CodeIgniter (haven't used it myself but I heard it's great, sounds like what you need). 因此,根据您提供的背景信息,我会说使用像CodeIgniter这样的PHP框架(我自己没有使用过,但是我听说它很棒,听起来像您所需要的)。

The project should be done in a month and is very time sensitive. 该项目应在一个月内完成,并且对时间非常敏感。 Is 1 month enough for learning with and building a website in RoR? 1个月足够学习RoR并建立网站吗?

As its been said before, stick with what you know if the deadline is short. 如前所述,如果截止日期很短,请坚持使用您所知道的信息。

I am OK using a PHP framework. 我可以使用PHP框架。 Is this a bad idea? 这是一个坏主意吗? If not, which PHP framework is closest to Rails in terms of programming convenience. 如果不是,那么就编程方便性而言,哪个PHP框架最接近Rails。

CakePHP is very ruby like and I have been told that its a good stepping stone for PHP programmers to get in to Ruby and MVC. CakePHP非常像红宝石,有人告诉我它是PHP程序员接触Ruby和MVC的良好垫脚石。

use php + Zend Framework it's have all features of ror and more faster 使用php + Zend Framework,它具有ror的所有功能,并且速度更快

ror is very slow, very expensive, and require powerful server ror非常慢,非常昂贵,并且需要功能强大的服务器

 * The project should be done in a month and is very time sensitive. Is 1 month enough for learning with and building a website in RoR? 

it's enough to learn Zend Framework 学习Zend Framework就足够了

 * Writing direct SQL queries is one of my strengths and I would like to use it. I heard that RoR is a pain to use if I am writing SQL queries directly. Is this true? Or can I just say execute a query, give me the results (as a list or dictionary) and then I will tell you how to render them? 

should to writing SQL queries directly, ror make very slow and unoptimization queries 应该直接编写SQL查询,所以ror会进行非常缓慢且未优化的查询

 * I am OK using a PHP framework. Is this a bad idea? If not, which PHP framework is closest to Rails in terms of programming convenience. 

all you need is mvc framework, I offer you take Zend Framework 您需要的只是mvc框架,我为您提供Zend框架

For 1 month project use what you know better! 对于1个月的项目,请使用您更了解的内容! Until now I have used Qcodo and Qcubed, but you generate your interface only from the database. 到目前为止,我已经使用了Qcodo和Qcubed,但是您只能从数据库生成接口。 Any PHP framework uses DSL. 任何PHP框架都使用DSL。 I love Python as language but never used. 我喜欢Python作为语言,但从未使用过。 I was looking Ruby On Rails yesterday and it seems pretty nice. 昨天我在看Ruby On Rails,看起来不错。 RoR has provided a new way to write agile web applications, but now there is grails too. RoR提供了一种编写敏捷Web应用程序的新方法,但是现在也有麻烦了。 Grails is written in Groovy, runs over the JVM and is dynamic language. Grails用Groovy编写,在JVM上运行并且是动态语言。 The strengh of Grails is that can use any Java code and framework but with the simplicity of a dynamic language. Grails的优势在于可以使用任何Java代码和框架,但具有动态语言的简单性。 With Grails you can do the same things of Rails and even more. 使用Grails,您可以完成Rails的相同任务甚至更多。

My advice, use what you know better, meanwhile learn Grails, this is what I am doing now. 我的建议是,使用您所了解的知识,同时学习Grails,这就是我现在正在做的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM