It's possible make a bridge from Java to php file?
I've got an application written in Java and I need execute http://piwik.org/ that is written in PHP. In the server I have PHP running but I cannot access from the browser to the php directory because all incoming traffic is redirected by apache to glassfish Application server.
So my idea is to use Java servlet to execute php files with:
Runtime.getRuntime().exec("php /path/to/file/file.php");
Then write the PHP output as java servlet response.
The only problems to accomplish this are:
How can I execute PHP cli that act like a browser?
Which parameters I need to pass to PHP to allow PHP to read or write cookie and session?
If you're using Apache anyway to proxy the traffic, I'd just exclude all traffic to Piwik and serve those directly from the file system / mod_php
/ php-fpm
/ whatever you normally use.
You could also use php-cgi
and pass the appropriate environment variables, but that complicates a lot of stuff, like you'd have to proxy the response back to the browser, too. Apache has already support for this, so don't implement another proxy in your application, do it directly in Apache.
You can exclude a directory from being proxied:
ProxyPass /piwik !
ProxyPass / 127.0.0.1:8080
ProxyPassReverse / 127.0.0.1:8080
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With