PHP scripting engine plugin v0.1

View: New views
3 Messages — Rating Filter:   Alert me  

PHP scripting engine plugin v0.1

by Daniel Ruthardt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi list,

I've been working on a PHP scripting engine plugin for Helma 1.x during
the last two weeks.
Although not finished. complete, or completely tested yet, I feel it is
ready to be released to the public.
A sample application is included.

The plugin is based on the Quercus PHP scripting engine [1] by Caucho,
which is part of the Resin [2] application server. Caucho offers both a
GPLv2 and a commercial pro version. So far, the plugin makes use of the
GPLv2 version only, which lacks Java bytecode compilation support.
Caucho claims, that the commercial pro version (which offers Java
bytecode compilation support is 4x faster than mod_php. I did some small
standalone (i.e. without Helma) tests, which resulted in the pro version
being at least twice as fast as mod_php and sometimes even faster as
compiled Rhino JS.

You can download the plugin from [3]. The release file is meant as
overlay over a Helma 1.x (I only tested it with Helma 1.6.2)
distribution. So to test it, simply extract a new Helma distribution [4]
file and extract the plugin release file over it. The plugin release
file contains three new libraries (quercus.jar, resin.jar and warp.jar),
a test application (welcomePhp), an internal database for the test
application (db/welcomePhp), static files for the test application and
most important a simple script to start Helma (start_with_php.sh).

IMPORTANT:
For some reason (still need to find out why), the plugin only works when
you start Helma like the included script file does it (i.e. it does not
work, if you start Helma with the original start.sh script file which
starts Helma via the launcher.jar).

About Warp:
Just to have it mentioned: the php plugin is hosted at Sourceforge.
Warp, the project under which it is hosted, is a (my) fork of Helma 1.x.
The intention of the fork is to rewrite and extend a pluggable Helma 1.x
from the inside (compared to Helma NG). The fork allows me to do that in
a flexible and permissive way. No need to look at the SVN yet, the
current version does not differ from Helma (except being reformatted a
little bit). Although it will soon differ substantially, it will always
remain compatible to Helma 1.x (including future versions, at least that
is the main goal). Additionally I will always provide functionality as
Helma 1.x plugins (like the php plugin) too, if possible (if it is
possible to have such functionality as Helma plugin). What was known as
Warp before (the Warp repository implementation) [5] will soon be
rewritten and included in Warp.

Kind regards,
Daniel

[1] http://quercus.caucho.com/
[2] http://caucho.com/resin/
[3]
http://sourceforge.net/project/showfiles.php?group_id=235880&package_id=287402
[4] http://dev.helma.org/download/
[5] http://dev.helma.org/wiki/Related+Projects/#Warp
_______________________________________________
Helma-user mailing list
Helma-user@...
http://helma.org/mailman/listinfo/helma-user

Parent Message unknown Re: PHP scripting engine plugin v0.1

by Maksim Lin for technical support mailling lists :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Daniel,

Thanks for the pointer to Quercus! - I didnt even realise there was a
Java implementation of PHP.
I'm not sure if I would use it to write PHP scripts inside my Helma
apps, but its very cool how you've been able to integrate running php
scripts directly and pretty cleanly within Helma!
However I could see myself using Quercus as a way of running PHP apps
alongside Helma apps...

Also I notice you include the Resin.jar but in thier .war download, it
only seems to depend on resin-util.jar and script-10.jar which are much
smaller (643+27kb vs 8.9Mb) so perhaps you might be able to use that
instead for your package?

Maks.

> -----Original Message-----
> From: helma-user-bounces@...
> [mailto:helma-user-bounces@...] On Behalf Of Daniel Ruthardt
> Sent: Tuesday, 12 August 2008 00:58
> To: Helma User Mailing List; Helma Developer Mailing List
> Subject: [Helma-user] PHP scripting engine plugin v0.1
>
> Hi list,
>
> I've been working on a PHP scripting engine plugin for Helma
> 1.x during the last two weeks.
> Although not finished. complete, or completely tested yet, I
> feel it is ready to be released to the public.
> A sample application is included.
>
> The plugin is based on the Quercus PHP scripting engine [1]
> by Caucho, which is part of the Resin [2] application server.
> Caucho offers both a
> GPLv2 and a commercial pro version. So far, the plugin makes
> use of the
> GPLv2 version only, which lacks Java bytecode compilation support.
> Caucho claims, that the commercial pro version (which offers
> Java bytecode compilation support is 4x faster than mod_php.
> I did some small standalone (i.e. without Helma) tests, which
> resulted in the pro version being at least twice as fast as
> mod_php and sometimes even faster as compiled Rhino JS.
>
> You can download the plugin from [3]. The release file is
> meant as overlay over a Helma 1.x (I only tested it with
> Helma 1.6.2) distribution. So to test it, simply extract a
> new Helma distribution [4] file and extract the plugin
> release file over it. The plugin release file contains three
> new libraries (quercus.jar, resin.jar and warp.jar), a test
> application (welcomePhp), an internal database for the test
> application (db/welcomePhp), static files for the test
> application and most important a simple script to start Helma
> (start_with_php.sh).
>
> IMPORTANT:
> For some reason (still need to find out why), the plugin only
> works when you start Helma like the included script file does
> it (i.e. it does not work, if you start Helma with the
> original start.sh script file which starts Helma via the
> launcher.jar).
>
> About Warp:
> Just to have it mentioned: the php plugin is hosted at Sourceforge.
> Warp, the project under which it is hosted, is a (my) fork of
> Helma 1.x.
> The intention of the fork is to rewrite and extend a
> pluggable Helma 1.x from the inside (compared to Helma NG).
> The fork allows me to do that in a flexible and permissive
> way. No need to look at the SVN yet, the current version does
> not differ from Helma (except being reformatted a little
> bit). Although it will soon differ substantially, it will
> always remain compatible to Helma 1.x (including future
> versions, at least that is the main goal). Additionally I
> will always provide functionality as Helma 1.x plugins (like
> the php plugin) too, if possible (if it is possible to have
> such functionality as Helma plugin). What was known as Warp
> before (the Warp repository implementation) [5] will soon be
> rewritten and included in Warp.
>
> Kind regards,
> Daniel
>
> [1] http://quercus.caucho.com/
> [2] http://caucho.com/resin/
> [3]
> http://sourceforge.net/project/showfiles.php?group_id=235880&p
> ackage_id=287402
> [4] http://dev.helma.org/download/
> [5] http://dev.helma.org/wiki/Related+Projects/#Warp
> _______________________________________________
> Helma-user mailing list
> Helma-user@...
> http://helma.org/mailman/listinfo/helma-user
>
_______________________________________________
Helma-user mailing list
Helma-user@...
http://helma.org/mailman/listinfo/helma-user

Re: PHP scripting engine plugin v0.1

by Daniel Ruthardt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Maks,

Quercus is pretty much the best product I was able to find to connect Java and PHP. Of course I do know, that native PHP is able to use Java, but with Quercus its even easier to use Java from within PHP, but most important the integration effectively works in both directions.
After having finished the first release of the PHP plugin, I can judge the Quercus engine as being quite easy to integrate in any Java application. Especially extending the the PHP context with additional modules (like the GlobalObject does it for JS) is extremely easy and far more straightforward than what I could see how it is done for the JS context.

The motivation however of writing the plugin was not that I prefer (Quercus) PHP over (Rhino) JS. Personally I like both languages and I can see advantages and disadvantages in both of them. Theoretically Helma was able to be extended with different scripting languages for years. But as far as I know, nobody ever did it. So the motivation was a proof of concept of the the scripting engine interface of Helma. My personal conclusion is, that the interface is at least good enough to allow various scripting language plugins to be developed. It could however be much better, if having a variety of different scripting languages would be a goal. Learning were things can be enhanced was another important motivation for writing the plugin.

Btw, these are some of my personal favorites of using PHP as scripting language for Helma.

class HopObject {
    public function size() {
       return "overriding can be so damn easy " . HopObjectJava::size();
    }

    public function __get($name) {
       return "generic getters and setters, finally!";
    }

    public function main_action() {
          import java.util.Date;
          echo new Date();
    }
}

Kind regards,
Daniel

PS: Thanks for the pointer to script-10.jar! Only having resin-util.jar is not enough, but the script-10.jar might have the missing things. I will give it a try.


Maksim Lin for technical support mailling lists wrote:
Hi Daniel,

Thanks for the pointer to Quercus! - I didnt even realise there was a
Java implementation of PHP. 
I'm not sure if I would use it to write PHP scripts inside my Helma
apps, but its very cool how you've been able to integrate running php
scripts directly and pretty cleanly within Helma!
However I could see myself using Quercus as a way of running PHP apps
alongside Helma apps...

Also I notice you include the Resin.jar but in thier .war download, it
only seems to depend on resin-util.jar and script-10.jar which are much
smaller (643+27kb vs 8.9Mb) so perhaps you might be able to use that
instead for your package?

Maks.

  
-----Original Message-----
From: helma-user-bounces@... 
[helma-user-bounces@...] On Behalf Of Daniel Ruthardt
Sent: Tuesday, 12 August 2008 00:58
To: Helma User Mailing List; Helma Developer Mailing List
Subject: [Helma-user] PHP scripting engine plugin v0.1

Hi list,

I've been working on a PHP scripting engine plugin for Helma 
1.x during the last two weeks.
Although not finished. complete, or completely tested yet, I 
feel it is ready to be released to the public.
A sample application is included.

The plugin is based on the Quercus PHP scripting engine [1] 
by Caucho, which is part of the Resin [2] application server. 
Caucho offers both a
GPLv2 and a commercial pro version. So far, the plugin makes 
use of the
GPLv2 version only, which lacks Java bytecode compilation support. 
Caucho claims, that the commercial pro version (which offers 
Java bytecode compilation support is 4x faster than mod_php. 
I did some small standalone (i.e. without Helma) tests, which 
resulted in the pro version being at least twice as fast as 
mod_php and sometimes even faster as compiled Rhino JS.

You can download the plugin from [3]. The release file is 
meant as overlay over a Helma 1.x (I only tested it with 
Helma 1.6.2) distribution. So to test it, simply extract a 
new Helma distribution [4] file and extract the plugin 
release file over it. The plugin release file contains three 
new libraries (quercus.jar, resin.jar and warp.jar), a test 
application (welcomePhp), an internal database for the test 
application (db/welcomePhp), static files for the test 
application and most important a simple script to start Helma 
(start_with_php.sh).

IMPORTANT:
For some reason (still need to find out why), the plugin only 
works when you start Helma like the included script file does 
it (i.e. it does not work, if you start Helma with the 
original start.sh script file which starts Helma via the 
launcher.jar).

About Warp:
Just to have it mentioned: the php plugin is hosted at Sourceforge. 
Warp, the project under which it is hosted, is a (my) fork of 
Helma 1.x. 
The intention of the fork is to rewrite and extend a 
pluggable Helma 1.x from the inside (compared to Helma NG). 
The fork allows me to do that in a flexible and permissive 
way. No need to look at the SVN yet, the current version does 
not differ from Helma (except being reformatted a little 
bit). Although it will soon differ substantially, it will 
always remain compatible to Helma 1.x (including future 
versions, at least that is the main goal). Additionally I 
will always provide functionality as Helma 1.x plugins (like 
the php plugin) too, if possible (if it is possible to have 
such functionality as Helma plugin). What was known as Warp 
before (the Warp repository implementation) [5] will soon be 
rewritten and included in Warp.

Kind regards,
Daniel

[1] http://quercus.caucho.com/
[2] http://caucho.com/resin/
[3]
http://sourceforge.net/project/showfiles.php?group_id=235880&p
ackage_id=287402
[4] http://dev.helma.org/download/
[5] http://dev.helma.org/wiki/Related+Projects/#Warp
_______________________________________________
Helma-user mailing list
Helma-user@...
http://helma.org/mailman/listinfo/helma-user

    
_______________________________________________
Helma-user mailing list
Helma-user@...
http://helma.org/mailman/listinfo/helma-user

  

_______________________________________________
Helma-user mailing list
Helma-user@...
http://helma.org/mailman/listinfo/helma-user