I have a PHP 5 based site which I need ti integrate with a range of Java classes I have created. Basically I have created a webservice to post xml to a file, once in that file I parse the xml and want to call methods within a java file.
I have no idea how to call java functions from PHP. I have looked into PHP/Java bridge but there is nothing out there which describes clearly how to set this up.
Any help would be greatly appreciated,
You should consider the php-java-bridge. I have used it in the past on a project with a php front end and a java backend.
Quoting from their website:
The PHP/Java Bridge is an implementation of a streaming, XML-based network protocol, which can be used to connect a native script engine, for example PHP, Scheme or Python, with a Java virtual machine. It is up to 50 times faster than local RPC via SOAP, requires less resources on the web-server side. It is faster and more reliable than direct communication via the Java Native Interface, and it requires no additional components to invoke Java procedures from PHP or PHP procedures from Java.
Edit: I explained the disadvantages of using Quercus in another SO answer
You can use something like Thrift, Google Protocol Buffers or Avro to generate an interface and pass messages between the two languages. This is similar to what Facebook does to communicate between their PHP and other code.
Taking Google proto buffers as an example, you'll create a .proto file that defines some structure. You then run the proto compiler on that .proto file and it will generate corresponding PHP and Java classes which can be passed between the two languages over some middleware bridge.
Avro and Thrift both come with ways to create clients and servers that can talk to one another, where as I believe you are on your own with proto buffers.
Here is a tutorial on setting up a Thrift client in PHP: http://chanian.com/2010/05/13/thrift-tutorial-a-php-client/
Of coures the best idea is to go with a PHP implementation that runs ON the JVM and then you will have direct access to all Java libraries. You will be able to call Java objects like they are plain old PHP objects. JVM hosted dynamic languages are also getting very fast, especially w/ JDK 7. Quercus (an implementation of PHP that runs on the JVM) has actually been shown to be faster (4x faster!) than the mainstream PHP interpreter.
Also, if you are running PHP on the JVM then you can spawn threads and queue up background work... and all the other new libraries you'll be able to access... it is a huge win to switch to Quercus.
I'm not sure how code igniter is structured executes its code, but i just found this other question similar to this question: Run Java class file from PHP script on a website