Recently I wanted the RPG developer to call my PHP program for a process we are creating. By putting the business logic in PHP it allows us to use it internally in a Green Screen Application and on our website. We needed the ability to hash a password, send an email, and update a database record. Now this could all be done strictly using RPG and ILE, but PHP has functions built into the language to accomplish these goals such as password_hash() and mail().
I looked into using “PHP101: RPG Call PHP 101” on the YIP website, but the RPG developer found the Scott Klement article which is much simpler and easier to use and understand here:
You’ll have to register for the article but its worth it since his article is written well and has a zip file of the source code
By following scott klement’s example you have the RPG program run a command through PASE that calls the PHP to run your script.
md = 'PATH=$PATH:/usr/local/Zend/Core/bin && +
iconv -f 37 -t 819 | +
In his example he’s using Zend Core (the older version of PHP on i), so if your on Zend Server you’ll use these paths:
...and if you're on Zend Server 6 or above it will be
/usr/local/zendsvr6/bin/php and /www/zendsvr6/htdocs/MyPHPScript.php
Now to send parameters into the script you just add them to the command line command:
/usr/local/zendsvr/bin/php /www/zendsvr/htdocs/MyPHPScript.php parameter1 parameter2 parameter3
You’ll use the $argv variable to access the parameters pass into the PHP script and use echo to send data back to the RPG program.
You may run into permissions issues with calling /usr/local/zendsvr/bin/php because Zend Server installed using QSECOFR, so you might have to add permissions to that path to the user calling PHP from RPG
Now your PHP Dev and RPG dev can collaborate on many projects that need to be done in house apps and the website! You can also try running the Command line PHP by doing CALL QP2TERM