Quercus 是 Java 环境中 PHP 的可行替代品吗?
对于任何偶然发现这个问题但不知道 Quercus 是什么的人 - 这是一个PHP 的实现是用 Java 完成的。
对于我目前正在从事的一个项目,我们通过 servlet 上的 cgi 提供 php 页面(我知道这很笨重,但这是支持遗留代码的要求)。 我很高兴发现 Quercus 项目,因为它看起来是将我们的项目转移到更纯粹的 Java 环境的一条有前途的途径。
我有几个关于 Quercus 的问题:
- 您在运输产品中使用过 Quercus 吗?
- 支持多少 php API?
- 您在使用它时遇到过哪些问题?
- 你能让它与 Jetty 一起工作吗? 您听说过它与 Jetty 一起使用吗? (我无法弄清楚)
For anyone stumbling upon this question who doesn't know what Quercus is - it is an implementation of PHP done in Java.
For a project that I am currently working on we serve php pages via cgi over servlets (I know it is clunky, but it is a requirement to support legacy code). I was excited to discover the Quercus project because it looked like a promising path to move our project to a more pure Java environment.
I have a few questions regarding Quercus:
- Have you used Quercus in a shipping product?
- How much of the php API is supported?
- What are any gotchas you have had working with it?
- Have you been able to make it work with Jetty? Have you ever heard of it working with Jetty? (I couldn't figure it out)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我用 WordPress 对其进行了测试,性能几乎是常规 Apache/PHP 下默认 WordPress 安装的两倍。 这仍然不是那么好。
我们确实注意到,虽然 Quercus 支持 PHP 中的curl 命令,但它并不支持所有的curl 选项。 所以自动插件下载不起作用。 这没什么大不了的,您可以随时下载插件并手动安装。 但这是一个危险信号,因为我们不知道还有什么可行的方法。 这也意味着 Facebook 的 PHP 库无法正常工作(很可能)。
如果您进行大量数据库连接和调用,您应该会看到该区域的性能大幅提升,因为将使用数据库连接池。
如果您正在编写代码,我会说这是一个非常可行的选择。 支持足够的 PHP,如果您发现某些功能不起作用,您可以使用受支持的其他 PHP 命令,或者仅使用 Java 命令。
I've tested it with WordPress and performance was almost double what a default WordPress install was under regular Apache/PHP. Which still isn't that great.
We did notice that while Quercus supports the curl commands in PHP, it doesn't support all the curl options. So automatic plugin downloads did not work. It wasn't that big of a deal, you can always download the plug-ins and install them manually. But this was a red flag since we didn't know what else would work. It also meant Facebook's PHP library wouldn't work right (most likely).
If you do a lot of database connections and calls, you should see a big performance boost in that area since database connection pooling will be used.
If you are writing the code, I would say it's a very viable option. Enough of PHP is supported that if you find something that doesn't work, you can use a different PHP command that is supported, or just use a Java command.
我做了一些评估 Quercus 的工作,它看起来很有希望,但不适用于我正在从事的项目,因为它是基于 Symfony 的,而 Quercus 不能很好地处理 Symfony 的反射性质。
我确实尝试让许多开源 PHP 项目使用它,发现它有一个相当完整的基于 PHP5 的 API。
你应该能够让它与 Jetty 一起工作。 我能够让它与 Tomcat 一起工作。
您确实可以将其视为 Java 应用程序中 JSP 的替代品。 它的工作方式与 JSP 的工作方式类似,将 PHP 编译为 Java 代码,就像将 JSP 编译为 Java 代码一样。
我相信使用 Jetty 的一大缺点是无法预编译 PHP 代码。
不过,即使您没有将 PHP 与 Java 混合使用,也有不少优点。 如果将两者混合起来,您将获得更多优势。
I did a little work evaluating Quercus and it looked promising, but did not work with the project I was working on, as it was Symfony based and the reflective nature of Symfony was not well handled by Quercus.
I did try getting a number of open source PHP projects working with it and found it to have a fairly complete PHP5 based API.
You should be able to get it working with Jetty. I was able to get it working with Tomcat.
You can really think of it as a replacement for JSP in a Java app. The way it works parallels how JSP works in that you compile PHP to Java code, just as you'd compile JSP to Java code.
I believe the big disadvantage of going with Jetty would be the inability to precompile the PHP code.
There are quite a few advantages, though, even if you aren't mixing PHP with Java. If you are mixing the two, you have even more advantages.
请参阅有关开发人员如何设法使用 Quercus 在 Google App Engine 上运行 PHP
注意:GAE 并未正式支持 PHP,但使用 Quercus 现在您可以运行它。
See link on how a developer managed to use Quercus to run PHP on the Google App Engine
NOTE: PHP is not officially supported in GAE but with Quercus you can run this now.
PHP 性能只有在 quercus 专业版中才会好。 因为专业版将PHP代码编译为java字节码。 所以会更快。
但开源版本仍然使用 PHP 解释器,如 http://en.wikipedia.org/wiki 中所述/Resin_Server
开源版本似乎不会有任何性能提升。
PHP performance will be good only in professional version of quercus. Because the professional version compiling the PHP code as java byte code. So it will be faster.
But the open source edition is still using the PHP interpreter as stated in http://en.wikipedia.org/wiki/Resin_Server
It seems there will be no performance boost up in open soruce edition.
好吧,如果您检查 Quercus 页面底部的版权,您会发现它更新到 06 年,所以我不保证任何 PHP 5.x 支持。
但为什么你想要这样的双重开销呢? 你也可以从 php 运行 java :)
Well, if you check the copyright at the bottom of the Quercus page you see it's updated until '06 so i don't garantee any PHP 5.x support.
But why would you even want to have the dual overhead like that? You can run java from php too :)