I've been trying to build a simple prototype application in Django, and am reaching the point of giving up, sadly, as it's just too complicated (I know it would be worth it in the long-run, but I really just don't have enough time available -- I need something up and running in a few days). So, I'm now thinking of going with PHP instead, as it's the method for creating dynamic web content I'm most familiar with, and I know I can get something working quickly.
我一直在尝试在Django中构建一个简单的原型应用程序,并且很可能已经达到了放弃的程度,因为它太复杂了(我知道从长远来看它是值得的,但我真的只是'有足够的时间 - 我需要一些东西,并在几天内运行)。所以,我现在正在考虑使用PHP,因为它是创建我最熟悉的动态Web内容的方法,而且我知道我可以快速完成某些工作。
My application, while simple, is probably going to be doing some reasonably complex AI stuff, and it may be that libraries don't exist for what I need in PHP. So I'm wondering how easy / possible it is for a PHP script to "call" a Java program or Python script or a program or script in another language. It's not entirely clear to me what exactly I mean by "call" in this context, but I guess I probably mean that ideally I'd like to define a function in, let's say Java, and then be able to call it from PHP. If that's not possible, then I guess my best bet (assuming I do go with PHP) will be to pass control directly to the external program explicitly through a POST or GET to a CGI program or similar.
我的应用程序虽然很简单,但可能会做一些相当复杂的AI工作,而且可能是我不需要在PHP中使用库。所以我想知道PHP脚本“调用”Java程序或Python脚本或用另一种语言编写的程序或脚本是多么容易/可能。我并不完全清楚在这种情况下“调用”究竟是什么意思,但我想我可能意味着理想情况下我想定义一个函数,比如说Java,然后能够从PHP调用它。如果那是不可能的,那么我想我最好的选择(假设我使用PHP)将通过POST或GET直接将控制权直接传递给外部程序到CGI程序或类似程序。
Feel free to convince me I should stick with Django, although I'm really at the point where I just can't figure out what model I need to produce the HTML form I want, which seems such a basic thing that I fear for my chances of doing anything more complex...
随意说服我,我应该坚持使用Django,虽然我真的不知道我需要什么模型来生成我想要的HTML表单,这似乎是一件基本的事情,我担心我的做任何更复杂的事情的机会......
Alternatively, anyone who can offer any advice on linking PHP and other languages, that'll be grateful received.
或者,任何能够提供关于PHP和其他语言链接的建议的人都会感激不尽。
2 个解决方案
#1
4
"where I just can't figure out what model I need to produce the HTML form I want, which seems such a basic thing that I fear for my chances of doing anything more complex"
“我无法弄清楚我需要哪种模型来生成我想要的HTML表单,这似乎是一件基本的事情,我担心我有机会做更复杂的事情”
Common problem.
Root cause: Too much programming.
根本原因:编程太多。
Solution. Do less programming. Seriously.
解。少编程。认真。
Define the Django model. Use the default admin pages to see if it's right. Fix the model. Regenerate the database. Look at the default admin pages. Repeat until the default admin pages work correctly and simply.
定义Django模型。使用默认管理页面查看是否正确。修复模型。重新生成数据库。查看默认管理页面。重复此操作,直到默认管理页面正常工作。
Once it's right in the default admin pages, you have a model that works. It's testable. And the automatic stuff is hooked up correctly. Choices are defined correctly. Computations are in the model mmethods. Queries work. Now you can start working on other presentations of the data.
一旦它在默认管理页面中正确,您就有了一个可行的模型。这是可以测试的。自动化的东西正确连接起来。选择是正确定义的。计算在模型中。查询工作。现在,您可以开始处理其他数据表示。
Django generally starts (and ends) with the model. The forms, view and templates are derived from the model.
Django通常以模型开始(并结束)。表单,视图和模板都是从模型中派生出来的。
#2
2
For an easy access of Java classes from PHP scripts you can use a php-java bridge.
为了从PHP脚本轻松访问Java类,您可以使用php-java桥。
There is a open source solution: http://php-java-bridge.sourceforge.net/pjb/
or a solution from Zend (http://www.zend.com/en/products/platform/product-comparison/java-bridge).
有一个开源解决方案:http://php-java-bridge.sourceforge.net/pjb/或Zend的解决方案(http://www.zend.com/en/products/platform/product-comparison/java -桥)。
I'm more familiar with the later, and it's very easy and intuitive to use.
我对后者比较熟悉,而且使用起来非常简单直观。
#1
4
"where I just can't figure out what model I need to produce the HTML form I want, which seems such a basic thing that I fear for my chances of doing anything more complex"
“我无法弄清楚我需要哪种模型来生成我想要的HTML表单,这似乎是一件基本的事情,我担心我有机会做更复杂的事情”
Common problem.
Root cause: Too much programming.
根本原因:编程太多。
Solution. Do less programming. Seriously.
解。少编程。认真。
Define the Django model. Use the default admin pages to see if it's right. Fix the model. Regenerate the database. Look at the default admin pages. Repeat until the default admin pages work correctly and simply.
定义Django模型。使用默认管理页面查看是否正确。修复模型。重新生成数据库。查看默认管理页面。重复此操作,直到默认管理页面正常工作。
Once it's right in the default admin pages, you have a model that works. It's testable. And the automatic stuff is hooked up correctly. Choices are defined correctly. Computations are in the model mmethods. Queries work. Now you can start working on other presentations of the data.
一旦它在默认管理页面中正确,您就有了一个可行的模型。这是可以测试的。自动化的东西正确连接起来。选择是正确定义的。计算在模型中。查询工作。现在,您可以开始处理其他数据表示。
Django generally starts (and ends) with the model. The forms, view and templates are derived from the model.
Django通常以模型开始(并结束)。表单,视图和模板都是从模型中派生出来的。
#2
2
For an easy access of Java classes from PHP scripts you can use a php-java bridge.
为了从PHP脚本轻松访问Java类,您可以使用php-java桥。
There is a open source solution: http://php-java-bridge.sourceforge.net/pjb/
or a solution from Zend (http://www.zend.com/en/products/platform/product-comparison/java-bridge).
有一个开源解决方案:http://php-java-bridge.sourceforge.net/pjb/或Zend的解决方案(http://www.zend.com/en/products/platform/product-comparison/java -桥)。
I'm more familiar with the later, and it's very easy and intuitive to use.
我对后者比较熟悉,而且使用起来非常简单直观。