1827807 Members
2965 Online
109969 Solutions
New Discussion

Re: Interactive PHP?

 
SOLVED
Go to solution
Paul Beaudoin
Regular Advisor

Interactive PHP?

Gents,

I have been playing with and goten to 'moderately experienced' with PHP when run under CSWS. I now have a requirement to use some of the logic in the PHP routines in other languages (predominatly COBOL). Is there any reasonable way to:
A) Run PHP interactively from the DCL prompt (i.e. no web server)
B) Call (or otherwise interface) PHP code to lower level languages?

Many thanks for any hints
Regards

Paul
13 REPLIES 13
Wim Van den Wyngaert
Honored Contributor

Re: Interactive PHP?

I use PHP in WASD (or better, I did some years ago).

I have a symbol php:=$cgi-bin:[000000]php
and use
$ php openvms.php
to execute the php file. This generates output (html) but simply on the screen.

Wim
Wim
Heinz W Genhart
Honored Contributor

Re: Interactive PHP?

Hi Wim

I just tried

php:==$disk:[directory-where-php-is]php

You have also to define the logical phpshr

DEFINE phpshr disk:[directory-where-php-is]phpshr

After definig the logical name I can execute php scripts e.g.

$ php search_file.php

Regards

Heinz
Paul Beaudoin
Regular Advisor

Re: Interactive PHP?

Wim, Heinz,

Thanks for the replies they got me started, however after defining the symbol and logical this happens: (sorry about the formatting)

MGTAS1>php PHP_OPENVMS.PHP;1
Content-type: text/html
X-Powered-By: PHP/4.3.2



Warning: dl(): Unable to load dynamic library '/php_root/extensions/php_openvms' - no such file or directory in /apache$c
ommon/php/scripts/php_openvms.php
on line 7

Testing the OpenVMS extension





Fatal error: Call to undefined function: openvms_cvt_filename() in /apache$common/php/scripts/php_openvms.php on lin
e 29


Apparently when run this way, the PHP exe can't find the modules needed to complete the operation. This is consistant when running a number of different scripts. It also can't find other script modules in the same directory (Function libraries) These work fine when run from the web server. Is there further incantation to let PHP.EXE know where these are? - They are there!

Many thanks

Paul

Robert Atkinson
Respected Contributor

Re: Interactive PHP?

Paul, you coulod try this in the top of your script as a work-around :-


if (!extension_loaded('php_openvms')) {
if (!dl('php_openvms.exe')) {
die("Unable to load OpenVMS extension");
}
}
?>
Robert Atkinson
Respected Contributor

Re: Interactive PHP?

Having said that, the extension should load from PHP.INI.

Check PHP.INI and make sure this line is uncommented :-

'extension=php_openvms.exe'

Rob.
Robert Atkinson
Respected Contributor
Solution

Re: Interactive PHP?

One last thing, you should have these logicals and files for PHP to operate correctly. From the output you gave, it looks like soemthing's not quite right with your installation :-

GAMMA_ROB$$ sh log *php*

(LNM$SYSTEM_TABLE)

"PHPSHR" = "APACHE$COMMON:[PHP.BIN]PHPSHR.EXE"
"PHP_ROOT" = "$1$DGA114:[APACHE.APACHE.PHP.]"

(LNM$SYSCLUSTER_TABLE)

(DECW$LOGICAL_NAMES)
GAMMA_ROB$$


GAMMA_ROB$$ dir php_root:[extensions]

Directory PHP_ROOT:[EXTENSIONS]

PHP_BCMATH.EXE;1 72/105 16-SEP-2005 10:08:24.24 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_BZ2.EXE;1 226/245 16-SEP-2005 10:08:29.60 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_CALENDAR.EXE;1 56/70 16-SEP-2005 10:08:44.20 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_CTYPE.EXE;1 26/35 16-SEP-2005 10:08:49.65 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_DBA.EXE;1 159/175 16-SEP-2005 10:09:26.27 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_EXIF.EXE;1 101/105 16-SEP-2005 10:09:36.55 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_FTP.EXE;1 1742/1750 16-SEP-2005 10:09:55.84 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_GD.EXE;1 528/560 16-SEP-2005 10:11:20.29 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_ICONV.EXE;1 19/35 16-SEP-2005 10:11:24.99 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_LDAP.EXE;1 83/105 16-SEP-2005 10:11:35.62 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_MHASH.EXE;1 285/315 16-SEP-2005 10:11:40.23 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_MYSQL.EXE;1 362/385 16-SEP-2005 10:13:45.57 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_OCI8.EXE;1 184/210 16-SEP-2005 10:14:00.93 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_ODBC.EXE;1 156/175 16-SEP-2005 10:14:18.37 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_OPENSSL.EXE;1 2347/2380 16-SEP-2005 10:14:33.86 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_OPENVMS.EXE;1 109/140 16-SEP-2005 10:14:44.95 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_ORACLE.EXE;1 76/105 16-SEP-2005 10:14:53.21 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_PCRE.EXE;1 207/210 16-SEP-2005 10:15:23.14 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_POSIX.EXE;1 36/70 16-SEP-2005 10:15:30.89 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_SESSION.EXE;1 99/105 16-SEP-2005 10:15:50.03 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_SOCKETS.EXE;1 98/105 16-SEP-2005 10:16:02.90 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_XML.EXE;1 362/385 16-SEP-2005 10:16:41.70 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_ZIP.EXE;1 112/140 16-SEP-2005 10:16:46.55 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)
PHP_ZLIB.EXE;1 201/210 16-SEP-2005 10:17:00.87 [AP_HTTPD,APACHE$WWW (RWED,RWED,RE,RE)

Total of 24 files, 7646/8120 blocks.
GAMMA_ROB$$
Paul Beaudoin
Regular Advisor

Re: Interactive PHP?

Robert,

Thanks for your (numerous!) replies. It was the last one that worked. The PHP_ROOT logical seems to let PHP.EXE know where everything is.

Thanks and regards

Paul
I. Melamed
New Member

Re: Interactive PHP?

Our CSWS config has a file
APACHE$COMMON:[000000]PHP_SETUP.COM. I ran it at the DCL prompt and was then able to run PHP, here is what I tried:
$ @APACHE$COMMON:[000000]PHP_SETUP
$ php
echo test
Exit
Content-type: text/html
X-Powered-By: PHP/4.3.10

echo test

Hope this helps...By the way, this thread has me wondering...would it be possible to have the Purveyor webserver (old but capable system from Process Software) run PHP? We have CSWS and Purveyor installed on the same OpenVMS box using different ports, but Purveyor does not have "LoadModule" type functionality and does not "talk" PHP. I guess I could try and setup PHP in the CGI-BIN directory. Any thoughts on how to configure this would be appriciated...

Ira M.
Robert Atkinson
Respected Contributor

Re: Interactive PHP?

Because PHP needs to hook into the HTTP server at such a low level, I don't think it'll run properly at CGI level.

I can't find any documentation that says it supports PHP either, although you could check with Process or Hoff.

To be honest, CSWS (Apache) is so easy to install and set up, I wouldn't even bother with trying to get Purveyor working. The VAMP (VMS-Apache-MySQL-PHP) board at http://vamp.issinoho.com/ will help you get going if you have any problems.

If you don't fancy Apache, then WASD (http://wasd.vsm.com.au/) is just as good, and supports all the lastest code sets.

Rob.
Paul Beaudoin
Regular Advisor

Re: Interactive PHP?

Ira,

Thanks for the aditional info - it is much the same as Robert gave but maybe in a more concise format :-).

I have another related question (paramater passing) but think I should open a new thread.

Thanks again to all

Paul
Paul Beaudoin
Regular Advisor

Re: Interactive PHP?

Thread closed - thanks to all. Problem solved
Hoff
Honored Contributor

Re: Interactive PHP?

There are some open security bugs reported against Purveyor. That aside, probably the biggest problem with Purveyor here is this:

"Support for Purveyor was discontinued in 1997"

I'd be a little surprised if you could not get php to work via CGI, whether Purveyor or otherwise. I regularly ran DCL-based CGI underneath Purveyor. It'll be fairly slow and inefficient, since you'll probably end up using subprocesses and the "text path" into the web server.

As for calling php from another language, the hideously inefficient and massively brute-force solution would be a connection into port 80, or 443 or other local port from the compiled code, and to pass http/https commands back and forth. But if you have the CPU cycles to spare...

Apache / SWS or WASD would be likely options as the web server, and a LightTPD port (if it doesn't exist) might be an interesting project.

You could jacket the calls and run in a subprocess or server process or such, too. (That's basically what connecting into port 80 does, and it's a bit more local work to create and maintain. Using port 80 or 443 is arguably somewhat more flexible and somewhat less work, and probably not really any more inefficient. :-) )

I don't know of a compiled php around (and particularly one that produced VAX, Alpha or Itanium object code for use with OpenVMS), but I haven't made a serious look for a compiler. That lack would eliminate a more direct call into the php code. All I've worked with have been interpreters.

Stephen Hoffman
HoffmanLabs
Paul Beaudoin
Regular Advisor

Re: Interactive PHP?

Thanks Hoff for the pointers. I had in mind that, once I established how (and if) PHP could be run from the command line a simple LIB$SPAWN would do the call with logicals /symbols used as appropriate to do any necessary return. I have not got the full details of requirements yet but given the answers, this approach seems OK. Not, as you point out, in the most efficiant manner.

Regards

Paul