PDA

View Full Version : [Note:] Integrating PHP 5.0.2 with Laszlo


d~l
10-24-2004, 05:25 AM
See shorter description of PHP installation posted further down this thread .. 14-03-2005.

...............


Summary

Following research into ways of using PHP with Laszlo, these are notes of my installation of PHP 5.0.2 on Tomcat 5.0.28 to integrate wth Laszlo 2.2 for running Pre-Processed Requests.

There are other methods of connecting Apache to Tomcat server via mod_jk2 connector.

But for running Pre-Processed hello.php.lzx Requests in Laszlo apps, PHP must coexist with LPS on the Tomcat server.


Pre Reading

Read LPS document on Request types here .. LPS Request Types (http://www.laszlosystems.com/lps/docs/lzx-developers-guide/lps-request-types.html)

Preprocessed Requests

The LPS also supports using dynamic, server-side back-end processors (e.g., PHP, JSP) to generate LZX application source code before the LPS compiles and serves it. For URLs that end in .lzx for which the LPS can not find a matching source file on disk, the LPS will strip off the .lzx suffix and run attempt to get the content of the modified URL via an HTTP GET. The contents returned

should be a properly formatted LZX file. The LPS will then compile and server an application based on the dynamically generated source code. For example see the hello.jsp file in the examples

directory. This example generates a Laszlo application that contains information about the current time and session. You can see the generated LZX source at:

http://localhost:8080/lps-2.2/examples/hello.jsp.lzx?lzt=source

and the generated application at:

http://localhost:8080/lps-2.2/examples/hello.jsp.lzx


Related Threads

Laszlo and PHP (http://www.laszlosystems.com/developers/community/forums/showthread.php?threadid=1254)


Installation of PHP 5.0.2 on Tomcat Server

Shut down Tomcat server.

If PHP is not already installed, download and install binary version of PHP 5.0.2 into c:\php\

PHP downloads page (http://www.php.net/downloads.php#v5)

PHP 5.0.2 zip package (http://www.php.net/get/php-5.0.2-Win32.zip/from/a/mirror)

Also download separately ..

Collection of PECL modules (http://www.php.net/get/pecl-5.0.2-Win32.zip/from/a/mirror)

Download PHPServlet (http://tools.herberlin.de) from http://www.herberlin.de/index.html

Install PHPServlet as a normal Tomcat webapp (drop PHPServlet.war into %TOMCAT_HOME%\webapps\).

In text editor, open installed %TOMCAT_HOME\webapps\PHPServlet\WEB-INF\web.xml

and set the path to the PHP 5.0.2 executable ...

<init-param>
<param-name>php.executable</param-name>
<param-value>c:/php/php-cgi.exe</param-value>
</init-param>


Note: the path must be to the PHP 5.0.2 CGI executable php-cgi.exe and not php.exe.

Also in PHPServlet\WEB-INF\web.xml, if you plan to access MySQL from PHPServlet/Tomcat you
must uncomment the web.xml configuration as below.

<!-- uncomment for MySQL connection -->
<!-- Seems that PHP 4.3 on Win32 needs this environment variable
to connect to MySql. Uncomment this if you have problems with
php and mysql on windows. (set to: c:/winnt/ if needed.)
-->
<init-param>
<param-name>SystemRoot</param-name>
<param-value>c:/windows/</param-value>
</init-param>


Otherwise, when attempting to access MySQL you will see a "Can't connect to MySQL - tcp/ip socket error (10106)" message.

The reason for this error is that PHP is working in CGI mode.

The CGI module option to send environment variables to CGI scripts is off by default.
This prevents PHP on Tomcat from obtaining the %SystemPath% and access to various dll's.
Therefore the path has to be set explicitly (by uncommenting the above web.xml configuration).

Ensure that phpservlet.jar is in your Java classpath.

To be sure, move phpservlet.jar (we only need one copy of phpservlet.jar in Tomcat) ..

from %TOMCAT_HOME%\webapps\PHPServlet\phpservlet.jar
into %TOMCAT_HOME%\common\lib\phpservlet.jar

Now open Control Panel | System | Advanced | Environment Variables

and insert into CLASSPATH ..

%TOMCAT_HOME%\common\lib;%TOMCAT_HOME%\common\lib\ phpservlet.jar

You will need to reboot server after changing Environment Variables.




Testing PHP 5.0.2 with PHPServlet/Tomcat


Startup Tomcat server. and watch logs for any errors in startup.

Check that PHPServlet has been installed as a new webapp.

Test that PHPServlet works by launching ..

http://localhost:8080/PHPServlet/

and then ..
http://localhost:8080/PHPServlet/phpinfo.php

to display PHP report

If no phpinfo report shows, you cannot go much further until this is seen to show that PHP is running on Tomcat.

At this point in the process, PHP is running as a separate application to Laszlo and if PHP applications
require to be used from within Laszlo apps they must be called via http://localhost:8080/PHPServlet/<phpapp>.




Building an Integrated LPS/PHPServlet Application


Shut down Tomcat server.

For test purposes create a clone of webapps\lps-2.2 into webapps\ and rename to lps-php

Startup Tomcat server.

Running webapps should now be:-

webapps\lps-2.2\ Laszlo apps only
webapps\lps-php\ clone of Laszlo apps only
webapps\PHPServlet\ PHP apps only

Shut down Tomcat server.

Rename webapps\PHPServlet\index.html to webapps\PHPServlet\index-php.html

Copy the entire contents of webapps\PHPServlet\*.* into webapps\lps-2.2\*.* (including sub-folders)

You will find a file management utility such as Total Commander (http://www.ghisler.com) to be useful for this.

Ensure that all sub-folders are copied / merged into classes and libs folders.

Now the webapps\lps-2.2\WEB-INF\web.xml file will need to be edited into a new merged web.xml.
The new web.xml will contain the servlet mappings from the two merged webapps (lps-2.2 and PHPServlet).

To make this easier, a sample WEB-INF\web.xml is included in the zip attachment.

Also take the \php\*.* folder in the zip attachment and copy into webapps\lps-php\examples\

This will create two files to test pre-processed requests - hello.php.lzx format.

webapps\lps-php\examples\php\hello.html
webapps\lps-php\examples\php\hello.php

Startup Tomcat server.

Test the new integrated Laszlo/PHP installation by launching the following

http://localhost:8080/lps-php/examples/hello.html to display hello.jsp.lzx

http://localhost:8080/lps-php/examples/hello.jsp.lzx to display hello.jsp.lzx

http://localhost:8080/lps-php/phpinfo.php to display PHP report

http://localhost:8080/lps-php/examples/php/hello.html to display hello.php.lzx

http://localhost:8080/lps-php/examples/php/hello.php.lzx to display hello.php.lzx



Final Deployment

The net result of this exercise:-

http://localhost:8080/lps-2.2/ for Laszlo and JSP applications only
http://localhost:8080/PHPservlet/ for PHP applications only
http://localhost:8080/lps-php/ for Laszlo, PHP and JSP applications

For test purposes, it is easier to keep these as separate webapps so that any webapp can be deleted as required.


Pros

dynamic scripting of Laszlo content using pre-processed requests.

access to rich features of PHP 5.0.2 including XML management (SimpleXML)

access to MySQL (or other) databases for importing/exporting XML files and Laszlo applications/resources.

access to a wide range of PHP applications to embed in Laszlo as the presentation layer


Cons

See Laszlo warning in this thread which suggests that pre-processed requests may not be supported in future.

pre processed requests (http://www.laszlosystems.com/developers/community/forums/showthread.php?threadid=1319)

Kranking simple hello.php.lzx application seems to go on ad infinitum.


Concluding

read related thread here .. (http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=1319)

Bloch wrote ..
The compiler is too slow. That's the main problem with this idiom for now. But you can use .php and .lzx together and we do. It's simply better practice to leave the .lzx fixed and have the program make runtime data requests back for session related information.

So on balance it seems that integrating PHP/LZX is not such a good move, because dynamic lzx script has to be re-compiled.

Better to call the php applications separately from static lzx.

d~l

d~l
10-24-2004, 05:31 AM
Here are the sample files in zip attachment ..

webapps\lps-php\examples\php\hello.html
webapps\lps-php\examples\php\hello.php
webapps\lps-php\WEB-INF\web.xml

rolfpf
03-06-2005, 07:52 PM
I followed the instructions as per http://www.laszlosystems.com/developers/community/forums/showthread.php?threadid=1321&highlight=phpservlet to try to get Laszlo to talk to PHP and then to MySQL.

I get to the tests where it says to test phpinfo.php. I get a 404 error when I try to open this php file.

I figure that it must be in %TOMCAT_HOME\webapps\PHPServlet\WEB-INF\web.xml since this is the only place that I can see where Laszlo (by way of the PHPServlet) can get access to the PHP CGI.

I am working on a Windows 2000 machine with Laszlo, PHP and MySQL all installed on the same machine.

My php-cgi is get as <param-value>c:/php/php-cgi.exe</param-value> (as it says in the instructions).

My SystemRoot is set as <param-value>c:/winnt/</param-value> because I am on Windows 2000.

Yet Tomcat (on port 8080) cannot see a php file. Why is this? Anyone have a resolution to this?

Regards
Rolf Pfotenhauer

d~l
03-07-2005, 02:41 AM
Caveat:

The above notes documented an early experiment to integrate PHP 5.0.2 with LPS
to explore dynamic scripting on the same Tomcat server.

However, dynamic scripting of Laszlo apps proved to be too slow since a compilation is needed.

But if you only require PHPServlet (CGI mode) on Tomcat to work with MySQL then it works fine;
i.e. calling PHP + MySQL apps from within Laszlo scripts.

Note that an alternative approach is to install Apache server plus PHP plus MySQL,
either on the same platform as Tomcat or on a remote "backend" server.

But this requires a server call each time a PHP script is run.
You would then have Tomcat and Apache on same platform but running on different ports.

With the integrated PHP on Tomcat, the PHP and MySQL scripts can be local to the Laszlo apps.

_____________________________________________

To get your Tomcat + PHP5 configuration working:-

First check that

php.ini is located in c:\winnt\php.ini

and that your PHP installation works in command line mode.

...

Now to check your Tomcat configuration.

There might be a missing note in the earlier posting.

In %TOMCAT_HOME%\conf\Catalina\localhost\

there should be a context.xml file for each application in %TOMCAT_HOME%\webapps\

e.g.
admin.xml
balancer.xml
jsp-examples.xml
lps-2.2.1.xml
lps-3.0.xml
manager.xml
phpservlet.xml
servlets-examples.xml

Check if you have a phpservlet.xml file here .. to match your webapps\phpservlet\

it should look like this ..


<?xml version='1.0' encoding='utf-8'?>
<!--
Context configuration file for PHPServlet
docBase="c:\tomcat5\webapps\phpservlet"
-->

<Context path="/phpservlet"
docBase="phpservlet"
debug="0"
privileged="true"
reloadable="true"
useNaming="true">


<!-- Uncomment this Valve to limit access to the app to localhost for obvious security reasons.
Allow may be a comma-separated list of hosts (or even regular expressions).

<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127.0.0.1"/>
-->

<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_phpservlet_log." suffix=".txt"
timestamp="true"/>

</Context>




As a side note, if you plan to use virtual hosts in Tomcat
you should clone the directory

%TOMCAT_HOME%\conf\Catalina\localhost\

to create similar directories in

%TOMCAT_HOME%\conf\Catalina\

named for each virtual host

e.g.
%TOMCAT_HOME%\conf\Catalina\localhost
%TOMCAT_HOME%\conf\Catalina\domainname1.com
%TOMCAT_HOME%\conf\Catalina\domainname2.com
%TOMCAT_HOME%\conf\Catalina\alpha.domainname3.org
%TOMCAT_HOME%\conf\Catalina\beta.domainname4.net

etc.

each virtual host directory containing the context files for the webapps in each virtual host.




And here is a copy of my experimental %TOMCAT_HOME%\webapps\phpservlet\WEB-INF\web.xml

(note: you can cut out some of the experiments if you want a PHP-only configuration, and in your case change c:/windows/ to c:/winnt/)



<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">


<web-app>

<servlet>
<servlet-name>PhpServlet</servlet-name>
<servlet-class>de.herberlin.phpservlet.PhpServlet</servlet-class>


<init-param>
<param-name>php.executable</param-name>
<!--
Enter the full qualified path to your php CGI executable here
e.g. c:/php/php-cgi.exe
-->
<param-value>c:/php/php-cgi.exe</param-value>
</init-param>


<!--
Configures if phpservlet accepts the multipart formdata
encoding (file upload). Set to true if you want to accept it.
-->
<init-param>
<param-name>php.use.multipart.formdata</param-name>
<param-value>false</param-value>
</init-param>

<!--
Seems that PHP 4.3 on Win32 needs this environment variable
to connect to MySql. Uncomment this if you have proplems with
php and mysql on windows. (set to: c:/winnt/ if needed.)
<init-param>
<param-name>SystemRoot</param-name>
<param-value>c:/windows/</param-value>
</init-param>
-->

<!--
Any servlet parameter that does not start with "php" is passed
to php as environment variable. If the value is a Java-System-Property,
the value of this property is given to php; else the value string as is is
passed to php.
The example shows how to pass the PATH - environment variable to php. PATH is
stored in the Java-System-Variable "java.library.path".
<init-param>
<param-name>PATH</param-name>
<param-value>java.library.path</param-value>
</init-param>
-->
</servlet>

<!-- added experiment for hello.php.lzx -->

<servlet>
<servlet-name>PhpLzxServlet</servlet-name>
<servlet-class>de.herberlin.phpservlet.PhpServlet</servlet-class>

<init-param>
<param-name>php.executable</param-name>
<!--
Enter the full qualified path to your php CGI executable here
e.g. c:/php/php-cgi.exe
-->
<param-value>c:/php/php-cgi.exe</param-value>
</init-param>
<!--
Configures if phpservlet accepts the multipart formdata
encoding (file upload). Set to true if you want to accept it.
-->
<init-param>
<param-name>php.use.multipart.formdata</param-name>
<param-value>false</param-value>
</init-param>

<!--
Seems that PHP 4.3 on Win32 needs this environment variable
to connect to MySql. Uncomment this if you have proplems with
php and mysql on windows. (set to: c:/winnt/ if needed.)
<init-param>
<param-name>SystemRoot</param-name>
<param-value>c:/windows/</param-value>
</init-param>
-->

<!--
Any servlet parameter that does not start with "php" is passed
to php as environment variable. If the value is a Java-System-Property,
the value of this property is given to php; else the value string as is is
passed to php.
The example shows how to pass the PATH - environment variable to php. PATH is
stored in the Java-System-Variable "java.library.path".
<init-param>
<param-name>PATH</param-name>
<param-value>java.library.path</param-value>
</init-param>
-->
</servlet>


<!-- added experiment for hello.php.lzx -->

<servlet-mapping>
<servlet-name>PhpServlet</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>


<servlet-mapping>
<servlet-name>PhpLzxServlet</servlet-name>
<url-pattern>*.php.lzx</url-pattern>
</servlet-mapping>


</web-app>



_____________________________________________


If phpinfo does not run after a restart of Tomcat server

http://localhost:8080/phpservlet/phpinfo.php

look for clues in
%TOMCAT_HOME%\logs\localhost_phpservlet_log.txt (this was set in your context file .. phpservlet.xml above).

and other logs ..
_____________________________________________

rolfpf
03-08-2005, 04:02 PM
It still does not work.

Here is what I did:

1. php.ini is now also located in c:\winnt\php.ini

2. PHP installation works in command line mode (including the use of PHP stand alone by way of the phpapache2.dll in Apache)

3. In %TOMCAT_HOME%\conf\Catalina\k2.bbvision.com\phpser vlet.xml is now defined (as you gave)

4 The file %TOMCAT_HOME%\webapps\phpservlet\WEB-INF\web.xml has the following defined (in brief to save space)

<param-name>php.executable</param-name>
<param-value>c:/php/php-cgi.exe</param-value>

and

<param-name>SystemRoot</param-name>
<param-value>c:/winnt/</param-value>


I restart the Tomcat server and performed

http://k2.bbvision:8080/phpservlet/phpinfo.php

I get a 404 error.

I looked for the %TOMCAT_HOME%\logs\catalina_phpservlet_log.txt

It does not exist because I suspect it is because of the 404 error. Any more ideas?

Regards
Rolf Pfotenhauer

d~l
03-09-2005, 01:46 AM
I suggest that you concentrate on getting the localhost version to work first before trying the virtual host (k2.bbvision).

If you have the full Tomcat server installed try going to http://localhost:8080/admin/

and log in ..

There should be this hierarchy

Tomcat Server
Service (Catalina)
Resources
User Definition

expand the Service Catalina tree and you should see

Host (localhost)
Host (k2.bbvision.com)


and within each of these expand to see Context files
and Logger for host files

This should reflect your webapps structure.

Looks o.k. ?

________________________________________

Here is a useful utility for diagnosing such problems

install FILEMON from http://www.sysinternals.com

start it up
set the INCLUDE filter to contain keyword - PHP
set the EXCLUDE filter to filter out background running processes (which add "noise" to the PHP report)

e.g.

explorer;

(you can see the background running processes in Windows Task Manager - Ctrl+Alt+Del)

then clear the FILEMON screen, and launch http://localhost:8080/phpservlet/phpinfo.php

and look for FILE NOT FOUND or similar clues in the report.

________________________________________


p.s.

Re: your absence of logger file .. check that you have these ..

in c:\Tomcat5\conf\server.xml


<Host name="localhost"
debug="0"
appBase="webapps"
unpackWARs="true"
autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false">

<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs"
prefix="localhost_log."
suffix=".txt"
timestamp="true"/>
</Host>

<Host name="k2.bbvision.com"
debug="0"
appBase="webapps"
unpackWARs="true"
autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false">

<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs"
prefix="k2.bbvision.com_log."
suffix=".txt"
timestamp="true"/>
</Host>

d~l
03-09-2005, 02:46 AM
I've just noticed that you refer to

I restart the Tomcat server and performed

http://k2.bbvision:8080/phpservlet/phpinfo.php

should this host name not be ..

http://k2.bbvision.com:8080/phpservlet/phpinfo.php ??

or is this a typo error?

Try .. http://localhost:8080/phpservlet/phpinfo.php

__________________________________________________


ALSO .. reading your post again ..


I figure that it must be in %TOMCAT_HOME\webapps\PHPServlet\WEB-INF\web.xml


.. and yet we are using phpservlet elsewhere .. note lower-case ..

.. Tomcat forces case sensitivity in paths

so run through your settings to ensure there is no conflict ..

"PHPServlet" is not the same as "phpservlet".

___________________________________________




To conclude: I have just tried in my Tomcat5+PHP5 configuration to access

http://localhost:8080/PHPServlet/phpinfo.php

and this causes the Error 404 page you report.

If I then try this ..

http://localhost:8080/phpservlet/phpinfo.php

(since my file names are lowercase)

the PHPinfo report comes up.


QED

rolfpf
03-10-2005, 07:40 PM
Still does not work. The suggestions that you made are valid ones, but I am afraid that they were all typo errors on my part.

In particular the line you show should be:
%TOMCAT_HOME\webapps\phpservlet\WEB-INF\web.xml

and the line URL should also have been shown:

http://k2.bbvision.com:8080/phpservlet/phpinfo.php

These two were correct. The only thing that I can see are some messages in the (attached) file catalina_admin_log.2005-03-10.txt

I have attached a zip with the four files:

catalina_admin_log.2005-03-10.txt
catalina_log.2005-03-10.txt
phpservlet.xml
Tomcat.bmp

The file Tomcat.bmp shows the Tomcat Admin screen with phpservlet shown open.

d~l
03-11-2005, 01:24 AM
puzzling ..

note that you uploaded the wrong files

zip contains ..

php folder (containing hello.php, hello.html)
WEB-INF (containing web.xml)

these seem to be the original example files I uploaded some time ago.

please post the files you mention .. and did you try FILEMON?

____________________________________________


Some later thoughts ..


check that %PHP_HOME% .. c:\php is added to environment PATH (separate with semi-colons)

check that phpservlet.jar is in %TOMCAT_HOME%\common\lib\

check that above path to phpservlet.jar is added to environment CLASSPATH

check in php.ini that cgi.force_direct is as below
cgi.force_redirect = 1

check that phpinfo.php can be run in PHP command line mode

place phpinfo.php into c:\php\
and in Command Line run
c:\php\> php phpinfo.php

check file access log created by FILEMON (sysinternals.com)

________________________

if all else fails, as another option you could install PHP5 on your Windows 2000 server

see notes here

http://www.macromedia.com/devnet/mx/dreamweaver/articles/php_iis.html

http://uk2.php.net/install.windows



________________________

d~l
04-13-2005, 11:23 AM
The earlier note I published to start off this thread was a bit too detailed and confusing, including steps which can be eliminated. Having just gone through this installation again (on lps-3.0b2), I'm adding this edited version.

Summary

Running PHP applications from within Laszlo canvas can be done in a number of ways:-

(a) calling PHP scripts in a remote server (such as Apache + PHP + MySQL)
(b) calling PHP scripts in the same Tomcat server containing LPS as a web app.

Assuming that you have installed and tested LPS (either the bundled version with Tomcat, or the core version) these are the steps to add PHP functionality to LPS.


Installation of PHP 5.0.2 on Tomcat

Shut down Tomcat server.

Download and install binary version of PHP 5.0.2 into c:\php\

PHP downloads page (http://www.php.net/downloads.php#v5)

PHP 5.0.2 zip package (http://www.php.net/get/php-5.0.2-Win32.zip/from/a/mirror)

Also download separately ..

Collection of PECL modules (http://www.php.net/get/pecl-5.0.2-Win32.zip/from/a/mirror)


Installation of PHPServlet on Tomcat


Download PHPServlet (http://tools.herberlin.de) from
http://www.herberlin.de/index.html

Expand the PHPServlet.war.zip archive (there is no need to install the full application of PHPServlet as webapp into Tomcat unless you require a separate PHP webapp). Simply copy the file phpservlet.jar from the archive into %TOMCAT_HOME%\common\lib\phpservlet.jar (note lowercase) to make PHP available to LPS.

Also in the PHPServlet.war.zip archive, inspect the file web.xml inside the WEB-INF folder. This file must be merged with the LPS web.xml file in %TOMCAT%\webapps\lps-3.0b2\WEB-INF\web.xml (or other path to your LPS).

Finally in the PHPServlet.war.zip archive copy phpinfo.php file into lps-3.0b2 folder.

Below is the result of merging the two web.xml files. Place this new web.xml in %TOMCAT%\webapps\lps-3.0b2\WEB-INF\web.xml
or if you are using the bundled version of LPS, place in
c:\Program Files\Laszlo Presentation Server 3.0b2\Server\lps-3.0b2\WEB-INF\web.xml
(backup your old web.xml before doing this).




<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<!-- this web.xml is the result of merging servlet definitions in the two
web.xml files from lps-3.0b2\WEB-INF\web.xml and PHPServlet\WEB-INF\web.xml -->

<web-app>
<!-- start of Laszlo Servlet definitions -->

<display-name>LPS</display-name>
<description/>

<servlet>
<servlet-name>LPS</servlet-name>
<servlet-class>com.laszlosystems.servlets.LZServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>LZViewer</servlet-name>
<servlet-class>com.laszlosystems.servlets.LZViewer</servlet-class>
</servlet>

<servlet>
<servlet-name>AuthenticationServlet</servlet-name>
<servlet-class>AuthenticationServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>LPS</servlet-name>
<url-pattern>*.lzx</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>LPS</servlet-name>
<url-pattern>*.lzo</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>LZViewer</servlet-name>
<url-pattern>/LZViewer</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>AuthenticationServlet</servlet-name>
<url-pattern>/AuthenticationServlet</url-pattern>
</servlet-mapping>

<!-- end of Laszlo Servlet definitions -->

<!-- start of PHPServlet definitions -->

<servlet>
<servlet-name>PhpServlet</servlet-name>
<servlet-class>de.herberlin.phpservlet.PhpServlet</servlet-class>

<init-param>
<param-name>php.executable</param-name>
<!--
Enter the full qualified path to your php-cgi.exe executable here
e.g. c:/php/php-cgi.exe
-->
<param-value>c:/php/php-cgi.exe</param-value>
</init-param>


<!--
Configures if phpservlet accepts the multipart formdata
encoding (file upload). Set to true if you want to accept it.
-->
<init-param>
<param-name>php.use.multipart.formdata</param-name>
<param-value>false</param-value>
</init-param>

<!-- uncomment for MySQL connection -->
<!--
Seems that PHP 4.3 on Win32 needs this environment variable
to connect to MySql. Uncomment this belo if you have problems with
php and mysql on windows. (set to: c:/winnt/ if needed.)
-->

<!--
<init-param>
<param-name>SystemRoot</param-name>
<param-value>c:/windows/</param-value>
</init-param>
-->

<!--
Any servlet parameter that does not start with "php" is passed
to php as environment variable. If the value is a Java-System-Property,
the value of this property is given to php; else the value string as is is
passed to php.
The example shows how to pass the PATH - environment variable to php. PATH is
stored in the Java-System-Variable "java.library.path".

<init-param>
<param-name>PATH</param-name>
<param-value>java.library.path</param-value>
</init-param>
-->

</servlet>

<!-- PHP -->
<servlet-mapping>
<servlet-name>PhpServlet</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>

<!-- end of PHPServlet definitions -->

<mime-mapping>
<extension>swf</extension>
<mime-type>application/x-shockwave-flash</mime-type>
</mime-mapping>

<!-- need to define mime type for php files -->

<mime-mapping>
<extension>php</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.php</welcome-file>
</welcome-file-list>

</web-app>


Take note that the path to the PHP 5.0.2 executable is as follows ...

<param-value>c:/php/php-cgi.exe</param-value>
.. and not php.exe.


Testing PHP with LPS


Startup Tomcat server and watch logs for any errors in startup.

Test that PHPServlet works by launching ..

http://localhost:8080/lps-3.0b2/phpinfo.php

to display PHP report

If no phpinfo report shows, you have a problem with the installation. Retrace and check your steps.

When working you can run local php scripts from within LPS.

glasman
05-17-2005, 07:25 AM
Dear d~l
what about the php.ini do i have to change it?

and what about the PECL?

you didn't mention what to do with it?

d~l
05-17-2005, 08:32 AM
This page at docs.php.net says this .. (http://docs.php.net/en/install.pecl.html)


PECL for Windows users
Like with any other PHP extension DLL, to install move the PECL extension DLLs into the extension_dir folder and include them within php.ini. For example:

extension=php_extname.dll

After doing this, restart the web server.



...

regards php.ini

ensure that this line is uncommented

include_path = ".;c:\php\includes;"

...

if you plan to use MySQL
uncomment

extension=php_mysql.dll

...

if you plan to use PHP SOAP

; SOAP extension not in default php.ini
;--------------------------------------------------
extension=php_soap.dll
;--------------------------------------------------

There may be other tweaks I have forgotten.

Place php.ini in c:\windows\

____________________

The easiest way to get going is to not integrate with laszlo ... and just drop the phpservlet.war into tomcat5\webapps\

Restart the tomcat server and a new application phpservlet should be created .

then try

http://localhost:8080/phpservlet/phpinfo.php

to see the PHP report.

...

Later you might want to integrate PHP with laszlo app as detailed earlier.

I have PHP in phpservlet and laszlo apps.