Wordpress 可以被 Django 或 Ruby on Rails 之类的框架取代吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13862257/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:10:41  来源:igfitidea点击:

Can Wordpress be replaced by a Framework like Django or Ruby on Rails?

ruby-on-railsdjangowordpressframeworkswordpress-theming

提问by hcsnemrebured

I consider myself a well trained WordPress template developer, and i recently started to read books and documents about web app frameworks, particularly Django and Ruby on Rails. I didn't know any of the two languages, but i have no problems to learn another one or two. I really don't get the real benefits of using a framework, because i feel very confident about the power of WordPress. So, can anyone tell me the real benefits of using a framework? For example, Pinterest is made using Django, but i think that i can achieve the same results with a WordPress template using Javascript and CSS3. Can anyone tell me the differences/benefits of using a framework in that particular case?

我认为自己是一名训练有素的 WordPress 模板开发人员,最近我开始阅读有关 Web 应用程序框架的书籍和文档,尤其是 Django 和 Ruby on Rails。我不知道这两种语言中的任何一种,但是我可以学习另外一种或两种语言。我真的没有得到使用框架的真正好处,因为我对 WordPress 的力量非常有信心。那么,谁能告诉我使用框架的真正好处?例如,Pinterest 是使用 Django 制作的,但我认为我可以通过使用 Javascript 和 CSS3 的 WordPress 模板实现相同的结果。谁能告诉我在特定情况下使用框架的区别/好处?

回答by Chris Heald

You can achieve the same frontend with Wordpress, but what you will not be able to achieve is the speed and scale - and most importantly, maintainability - of an application based on a more application-oriented architecture.

您可以使用 Wordpress 实现相同的前端,但您无法实现的是基于更加面向应用程序的体系结构的应用程序的速度和规模——最重要的是可维护性。

Wordpress is highly flexible, but it's also slow, and needs an awful lot of TLC to be able to operate at any kind of significant scale. Its design allows for very flexible runtime modification of behavior, but this is also a bit of a Pandora's Box, since it means that code can end up running all over the place for any given page, which makes maintenance a nightmare.

Wordpress 非常灵活,但它也很慢,并且需要大量的 TLC 才能以任何类型的显着规模运行。它的设计允许对行为进行非常灵活的运行时修改,但这也有点像潘多拉魔盒,因为这意味着代码最终可能会在任何给定页面的所有地方运行,这使得维护成为一场噩梦。

Wordpress is extremely good at being a CMS, but once you start to push it outside of those bounds, you get into trouble, and find yourself having to write your own more abstract framework that runs inside of the context of Wordpress to be able to fulfill your application's needs.

Wordpress 非常擅长作为一个 CMS,但是一旦你开始将它推到这些界限之外,你就会遇到麻烦,并且发现自己必须编写自己的更抽象的框架,该框架在 Wordpress 的上下文中运行才能实现您的应用程序的需求。

That said, if you have an application that you can build in the context of Wordpress, I'd say go for it! Wordpress can be a wonderful tool for building a proof-of-concept or MVP. If it gets you up and running, then it may be the right choice over writing a full application. However, just be aware that you're going to hit some brick walls as your product design matures and your audience grows, unless your application fits within a rather narrow set of design requirements, so long-term, you may find yourself having to move to a custom application.

也就是说,如果您有一个可以在 Wordpress 上下文中构建的应用程序,我会说去吧!Wordpress 可以成为构建概念验证或 MVP 的绝佳工具。如果它能让您启动并运行,那么它可能是编写完整应用程序的正确选择。但是,请注意,随着产品设计的成熟和受众的增长,您将遇到一些障碍,除非您的应用程序符合相当狭窄的设计要求,从长远来看,您可能会发现自己不得不搬家到自定义应用程序。

Credentials: I've spent the last couple of years maintaining a Wordpress install that served over 25 million monthly uniques, and we had to get very clever to keep it running. We've since replaced it with a Rails application that serves pages somewhere on the order of 10x-30x faster, and is significantly more extensible as an application, allowing us to start exploring application potential that we really couldn't get with Wordpress.

凭据:在过去的几年里,我一直在维护一个 Wordpress 安装,每月提供超过 2500 万个唯一身份,我们必须非常聪明才能让它运行。此后,我们将其替换为 Rails 应用程序,该应用程序可以以 10 到 30 倍的速度为某个地方的页面提供服务,并且作为应用程序的可扩展性明显更高,这使我们能够开始探索使用 Wordpress 确实无法获得的应用程序潜力。

回答by pie6k

I once made the decision while working in some start-up to choose WordPressfor an advanced e-commerce, community-driven marketplace.

我曾经在一些初创公司工作时做出决定,选择WordPress作为高级电子商务、社区驱动的市场。

It. Was. The. Worst. Possible. Decision.

它。曾是。这。最差。可能的。决定。

This is how I was feeling:

我当时的心情是这样的:

enter image description here

在此处输入图片说明

At the beginning, it was looking good - you have an amazing community, plugins for everything etc. But let's face the truth - at it's root - WordPress is a blogging platform!

一开始,它看起来不错——你有一个很棒的社区,所有东西都有插件等等。但是让我们面对现实——从根本上说——WordPress 是一个博客平台

  • Every piece of content technically is a post.
  • It's a nightmare to create advanced item relationships
  • WordPress is notObject-Oriented. It has a lot of classes, but in general, you'll have to use a lot of functionslike get_post_metato manage core features of it. Something like $post->author()->comments()is just a dream.
  • Functionalities are not consistent. Some functions work one way, while others that seems to be very similar work in a different way. Sometimes you need some weird hacks to achieve task that seem to be simple. It makes you read the docs very often to see how a function that you're using for the 1000th time is working. (However, to be honest, I need to say that the WordPress documentation is great!)
  • 从技术上讲,每条内容都是一个post.
  • 创建高级物品关系是一场噩梦
  • WordPress不是面向对象的。它有很多类,但总的来说,您必须使用很多functionsget_post_meta来管理它的核心功能。类似的东西$post->author()->comments()只是一个梦想。
  • 功能不一致。一些功能以一种方式工作,而另一些看起来非常相似的功能以不同的方式工作。有时你需要一些奇怪的技巧来完成看似简单的任务。它让您经常阅读文档以了解您第 1000 次使用的函数是如何工作的。(但是,老实说,我需要说 WordPress 文档很棒!)

The WordPress community is doing a great job, but compared to ANY good Framework there is one main difference - Frameworks are just frameworks- they're a set of toolsand those tools are there to help you do yourproject. WordPress already is trying to be something that you might then change.

WordPress的社区做的非常出色,但相比于任何好的框架有一个主要的区别是-框架只是框架-他们是一组工具和这些工具在那里帮助你做你的项目。WordPress 已经在尝试成为您可能会改变的东西。

I'd say: If you need a car, you can buy some tools and build it, or you can buy a truck and try to modify it until it'll start to look like a car.

我会说:如果你需要一辆车,你可以买一些工具来建造它,或者你可以买一辆卡车并尝试修改它直到它开始看起来像一辆汽车。

I'll never use WordPress for anything that needs some well-organized, custom functionality.

我永远不会将 WordPress 用于任何需要一些组织良好的自定义功能的东西。

It's just good for blogs and some small e-commerce, but only because some guys did a great job modifying the truck to become a car creating functionalities of products, that are really posts, connecting them with promotions, that are really post-metas, and adding some promotions managers that in some magical way wrap it all together.

这对博客和一些小型电子商务来说非常有用,但这只是因为有些人做得很好,将卡车改装成汽车,创造了产品的功能,这真的是帖子,将它们与促销联系起来,真的是后期元,并添加一些促销经理,以某种神奇的方式将它们组合在一起。

回答by Kyle

I want to offer a dissenting opinion, even though I upvoted the top answer.

我想提出不同意见,即使我赞成最高答案。

Is Rails really special?

Rails 真的很特别吗?

Rails was created by David Hansson who extracted it from Basecamp, software that's replicated in a free Wordpress plugin, WP Project Manager. I think that's a pretty good indicator that Rails developers are underestimating PHP and Wordpress.

Rails 是由 David Hansson 创建的,他从 Basecamp 中提取了它,该软件在免费的 Wordpress 插件WP Project Manager 中复制。我认为这是一个很好的指标,表明 Rails 开发人员低估了 PHP 和 Wordpress。

MVC and WP

MVC 和 WP

True, it doesn't follow an MVC pattern. But if you use hooks, separate logic (in plugins) from views (in templates), then you'll have good code separation. (Also hint: custom post types are like models.)

确实,它不遵循 MVC 模式。但是,如果您使用hooks,将逻辑(在插件中)与视图(在模板中)分开,那么您将获得良好的代码分离。(另外提示:自定义帖子类型就像模型。)

Framework vs Application

框架与应用

As you can see, Wordpress can be treated like an application or a framework. It is an application, with all the components you'd expect to find in a framework. Right out of the box you have security, authentication, and extendibility. And it's meant to be extended.

如您所见,可以将 Wordpress 视为应用程序或框架。它是一个应用程序,具有您希望在框架中找到的所有组件。开箱即用,您就拥有安全性、身份验证和可扩展性。它意味着要延长。

Scaling

缩放

WP powers 18% of the internet's websites, including TechCrunch, Smashing Magazine, and (parts of) CNN. Seems there are ways to make WP scale. Disclaimer: I have no experience working on megasites like these, so I'm offering mere conjecture.

WP 为 18% 的互联网网站提供支持,包括 TechCrunch、Smashing Magazine 和(部分)CNN。似乎有办法让 WP 规模化。 免责声明:我没有在此类大型站点上工作的经验,因此我仅提供猜测。

WP Future

WP未来

The current abition of the WP community is to shift WP from a CMS to a framework. I think it's a natural progression considering that all the pieces are in place. And the Wordpress community is going strong.

WP 社区当前的目标是将 WP 从 CMS 转变为框架。考虑到所有部分都已就位,我认为这是一个自然的过程。Wordpress 社区正在变得强大。

回答by user1284631

Not really an answer, but a hint:

不是真正的答案,而是提示:

http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks

http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks

As if you can replace it completely... I think it is mostly a matter of logic flow. It depends how much imperative (Ruby on Rails) vs. descriptive (WordPress) programming you intend to do.

好像你可以完全替换它......我认为这主要是逻辑流程的问题。这取决于您打算进行多少命令式(Ruby on Rails)与描述性(WordPress)编程。

回答by maximus ツ

I don't think wordpress can replace rails, because wordpress have limited set of API and support as you compare it with RoR. Though wordpress is powerful tool for blogging application, but the same effect can be achieved with rails using gems like, Radiant CMS, Refinery CMS, Locomotive. Adding the power like ttd that can be done vary easily with rails is very difficult with wordpress.

我不认为 wordpress 可以取代 rails,因为当你将它与 RoR 进行比较时,wordpress 的 API 和支持集是有限的。虽然 wordpress 是博客应用程序的强大工具,但使用 Rails 也可以使用 gems 实现相同的效果,例如 Radiant CMS、Refinery CMS、Locomotive。添加像 ttd 这样的功能可以很容易地通过 rails 来完成,而 wordpress 则非常困难。

Same with authentication and authorization mechanism like devise and cancan. There is no easy option to do the same with wordpress.

与 devise 和 cancan 等身份验证和授权机制相同。没有简单的选择可以用 wordpress 做同样的事情。

Rails make the programmer's life easier. For whole web app I will always prefer to go with the rails.

Rails 使程序员的生活更轻松。对于整个 Web 应用程序,我总是更喜欢使用 Rails。

回答by virtualeyes

Wordpress cannot replace X framework, but the two can certainly complement each other.

Wordpress 不能替代 X 框架,但两者肯定可以互补。

For example a WP front end serving up CMS content with an attractive theme is pretty hard to beat; proxy to a back end server for custom content and voila, best of both worlds. Otherwise, WP will inevitably fall short of meeting every requirement and you'll find yourself going down the square-peg-round-hole rabbit hole, a painful place indeed; that's where X framework comes in, filling in the WP gaps.

例如,提供具有吸引力主题的 CMS 内容的 WP 前端很难被击败;代理到后端服务器以获取自定义内容,瞧,两全其美。否则,WP 将不可避免地无法满足所有要求,您会发现自己陷入了方钉圆孔的兔子洞,这确实是一个痛苦的地方;这就是 X 框架的用武之地,填补了 WP 的空白。

The notion that WP does not scale may have some truth to it, but for the general case, the 95%, it will handle whatever you throw at it, particularly with WP Cache or other caching plugin thrown into the mix.

WP 不能扩展的概念可能有一定的道理,但对于一般情况下,95%,它会处理你扔给它的任何东西,特别是当 WP Cache 或其他缓存插件加入混合时。

Some may say, well, you can build WP with Django or RoR! Heh, heh, you first ;-)

有人可能会说,好吧,您可以使用 Django 或 RoR 构建 WP!呵呵,你先;-)

FWIW, I avoid dynamic language frameworks in favor of their statically/strongly typed counterparts. Use WP for the bling, and static X framework for the speed/scalability/safety. Of course, that's a matter of preference, clearly some prefer runtime flexibility over compile time safety. I'm fully in the latter camp these days...

FWIW,我避免使用动态语言框架,而是使用它们的静态/强类型对应物。使用 WP 来提高速度,使用静态 X 框架来提高速度/可扩展性/安全性。当然,这是一个偏好问题,显然有些人更喜欢运行时的灵活性而不是编译时的安全性。这些天我完全在后者阵营中......

回答by Musthafa Ma

Wordpress is a great CMS any way Pros1. We can easily set up a website using free themes and plugins 2. There are numerous number of plugins to extend our website functionality 3. Excellent Community support 4. The CMS uses PHP and MySQL, somewhat easy to lean

无论如何,Wordpress 都是一个很棒的 CMS 优点1. 我们可以使用免费的主题和插件轻松建立网站 2. 有许多插件可以扩展我们的网站功能 3. 出色的社区支持 4. CMS 使用 PHP 和 MySQL,有点容易倾斜

Cons1. Updating plugins and themes regularly. 2. Slow 3. Malicious files can be easily injected.

缺点1. 定期更新插件和主题。2. 慢 3. 恶意文件很容易被注入。