It’s quite easy.
Download .war file from Quercus site (I used version 3.2.1).
Go to your glassfish/domains/domain1/lib, do a jar xvf quercus*.war and keep there all .jar files from WEB-INF subdirectory (you can delete the WEB_INF and other directories, which were created by extraction, also the .war can be deleted).
After that, create a servlet. A minimal one is a WEB-INF/web.xml like this:
<?xml version=”1.0” encoding=”UTF-8”?>
<web-app version=”2.5” xmlns=”http://java.sun.com/xml/ns/javaee” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd”>
You can now have a php.ini in WEB-INF/ subdirectory (which I used for upload_max_filesize=10000M).
Then create .php files as you would normally do. Pack everything into a war (I used netbeans to do all this stuff), deploy (for example using glassfish web interface) and there you go.
I was surprised how well it works and how easy it is to setup. The most difficult thing was to find where php.ini file was being found (contrary to everything I googled, it is relative to application directory, but strace to the rescue!).