6

There used to be a PHP extension that could load Java libraries and call methods in them. That was for PHP 4.

Is there a way to do the same in PHP 5?

hakre
  • 193,403
  • 52
  • 435
  • 836
AndreKR
  • 32,613
  • 18
  • 106
  • 168

3 Answers3

4

If you need Java integration in PHP 5, there is the Zend Server Java bridge:

http://www.zend.com/en/products/server-ce/

and "PHP/Java Bridge":

http://php-java-bridge.sourceforge.net/pjb/

EDIT

If you don't like either of the above options, then consider using Quercus. This is a Java implementation of PHP, that makes it easy to reference Java from within PHP and vice-versa

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • 2
    The first one is not PHP (but rather a kind of distribution with webserver, etc.) The second one is... well... a protocol to access a web service with PHP. I don't know why one would need software for that at all, you could just write it down using cURL. Completely useless. – AndreKR Dec 28 '10 at 21:54
  • @AndreKR Wouldn't it be the same has having JYthon or any of the other JVM implementations of another language? – johnny Sep 30 '13 at 13:45
1

Doesn't look like there's a built-in way, even the support in php4 was experimental. Doesn't really make sense to start up a Java Virtual Machine on each request for php. You could always use the shell-escaping capabilities (backtick operator) if you have to do something in Java but if you want to make something scalable it needs to be its own Java service and accept SOAP/REST or however you want to talk to it from php.

Abdullah Jibaly
  • 53,220
  • 42
  • 124
  • 197
  • You're right, it's not really reasonable. Unfortunately I have a third-party Java client library (or, alternatively, a .net version) I need to make a few calls to and I don't want to set up Tomcat or some other unmaintainable Java crap. I think, I'll go for the command line. – AndreKR Dec 29 '10 at 14:32
1

You could use Quercus. It's a PHP 5 runtime written in Java you can install on top of a JavaEE application server.

http://www.caucho.com/products/quercus/

Alexis Dufrenoy
  • 11,784
  • 12
  • 82
  • 124