If you ever need to compile Quercus from source and install it into your local Maven repository, this post is just for you. You need to have Subversion (or Git), Maven and Ant installed. Here are the steps:
Some time ago I had to download the Resin/Quercus source from an unofficial mirror repository on github, because the official Caucho SVN repository located at svn.caucho.com was down. This mirror repository is still available, but at the time of writing it seems a little outdated. If you are interested, perform these steps instead:
The Quercus webapp is now installed in your local Maven repository as version 4.0-SNAPSHOT. Include in your project's pom.xml as follows:
If you would like to see the other build targets for Resin/Quercus, execute the following command:
Bonus tip: you can always find a recent version of the Quercus WAR file at http://www.caucho.com/download/quercus-4.0.x.war, replacing 'x' with the latest version, e.g. http://www.caucho.com/download/quercus-4.0.28.war. You can find the latest version number by looking at Caucho Resin's version number on the website's download page. I figured this out once by guessing URLs to download the latest version. The Quercus website is not updated frequently enough to keep up with newer releases, but the files are actually there.
In my previous post I explained how to setup PHP and H2 database engine using a platform-independent Java stack, a.k.a. JAMP. I managed to get the Code Igniter framework running on JAMP, with some tweaking of the Code Igniter PDO driver. Here are the steps to make it work.
If you would like to skip these steps and jump immediately into some coding action, download the demo.
(Unzip and go into directory jamp-ci-demo/, then type `mvn jetty:run` from the command line. You need Maven installed to execute this command.)
First, checkout a copy of JAMP at github (git clone https://github.com/webdevelopersdiary/jamp.git).
Then download Code Igniter and put in the web root (src/main/webapp/).
Because Code Igniter likes pretty urls (ie. /controller_name/method_name) I added support for mod_rewrite to JAMP. It can parse mod_rewrite rules which are located in .htaccess directly in the web root (src/main/webapp/). Add src/main/webbapp/.htaccess with mod_rewrite rules:
Start up the JAMP web server (make sure .htaccess exists before starting the web server or it will have trouble discovering it, then execute mvn jetty:run). Verify Code Igniter is running correctly by going to http://localhost:8080/welcome (the default controller).
If you see a pesky error '$assign_to_config is an undefined variable', go to src/main/webapp/index.php and add
under the section 'CUSTOM CONFIG VALUES' (line 110 of index.php) and that should get rid of the error.
Next we configure Code Igniter to connect to the H2 database using PDO. Edit the configuration located at src/main/webapp/application/config/database.php and set these settings:
Next, we have to make a slight modification to Code Igniter's PDO driver. Change the method num_rows() from src/main/webapp/system/database/drivers/pdo/pdo_result.php to:
Everything should now be in place to connect to the H2 database using Code Igniter's ActiveRecord library. Let's test it! Create a test controller application/controller/test.php:
Voila! Go to http://localhost:8080/test and enjoy a working Code Igniter on H2 database using ActiveRecord :-)
Note: I used Code Igniter version 2.1.2, Quercus version 4.0.28 and H2 database version 1.3.167.