5250 to Web, a PHP Case Study on IBM I
Total Page:16
File Type:pdf, Size:1020Kb
5250 to Web: PHP Case Study on IBM i Alan Seiden PHP on IBM i consultant/developer email: [email protected] blog: http://alanseiden.com Strategic Business Systems, Inc. • Developing Web apps on IBM i (and iSeries, i5...) since 1996 • Based in Ramsey, New Jersey • IBM Business Partner . Power Systems hardware, software development, consulting • Zend Business Partner . Working with Zend since they brought PHP to IBM i in 2006 . We offer Zend’s training and Zend Server software to complement our own consulting/development services Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 2 Alan Seiden PHP on IBM i Developer / Consultant / Mentor • Contributor to IBM’s Redbook PHP: Zend Core for i5/OS • First IBM i developer certified in Zend Framework • Developer of IBM/COMMON’s “Best Web Solution” of 2009 Contact: [email protected] or 201-327-9400 Blog/articles: http://alanseiden.com Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 3 What we’ll discuss today • Update on Zend Server (new PHP install for i) • PHP basics quick overview . Focus on two ways to call CL/RPG from PHP • Case study: re-imagine green screens as web • Tips and techniques • Questions Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 4 PHP’s growth as web dev language (as of 2007) 34% of the internet runs on PHP ZF and PDT released, PHP 4 EOL 37% growth in PHP developers announced Zend Framework & Eclipse project (PDT) announced; i5/OS support 25M IBM, Oracle PHP 4 Endorse PHP Released PHP 5.0 (XML,SOAP,OOP) 20M Zend Studio • 1M Internet domains PHP • Zend Engine Proliferation 15M • Zend Founded Zeev Suraski & Yahoo! Standardizes Andi Gutmans 10M lead the on PHP development Rasmus of PHP 3 Lerdorf 5M PHP Introduces Internet PHP/FI Domains 1995 1997 1999 2000 2002 2003 2004 2005 2006 2007 Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 5 Who uses PHP? • Yahoo, eBay, Wikipedia, Facebook • Open source developers – 10,000+ projects • 7 million+ developers • Growing community of IBM i shops Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 6 Reasons for PHP’s success • Easy way to get data to Web . Generates ordinary HTML, viewable in any browser • Cross-platform: also runs on Windows, Linux, any mainstream OS • Open source with commercial backing . Managed by Zend, “the PHP company” . Contributors from community and corporations Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 7 Free, open source apps (fine on IBM i) WordPress blog/CMS MediaWiki (Wikipedia) ZenCart e-Commerce Bug Tracker SugarCRM (Mantis400.com) Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 8 PHP on i—always something new • 2004: i5php.net . Unofficial PHP binary for “i” available online • 2005: IBM and Zend got together • 2006: Zend Core for i5/OS . Official release with help from IBM . Professional technical support from Zend • 2007: Zend Studio: IDE/code editor and Zend Platform: performance booster and code tracer/monitor • 2008: Zend Framework supports “i” variant of db2 • 2009: Zend Server Beta for “i” . Combines the best of Core and Platform • 2010: Zend Server released Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 9 PHP on i—a comfortable fit • Runs completely on your good old “i” . Uses IBM’s native Apache web server . Shipped by IBM with v5r4 and higher . Connects directly to db2 database • Light on its feet . Efficient—runs well out of the box . Create useful functionality quickly; start small and grow • Plenty of room for sophistication in larger apps Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 10 ZendZend ServerServer Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 11 Zend Server for IBM i • Next generation PHP stack for IBM i . Best of Zend Core and Platform in one licensed program • Two license levels . Zend Server for IBM i Community Edition (CE) • Available at no charge per IBM partnership • Includes “Optimizer+” that speeds up code • One year silver (email) support . Zend Server for IBM i, a.k.a. Professional Edition (PE) • Subscription-based license • High value extra features, higher Support SLAs • Details of differences: . http://mikepavlak.blogspot.com/2010/08/i-want-to-do-php-on- ibm-i-so-what-do-i.html Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 12 Installation • http://www.zend.com/products/server/downloads . Click on the “IBM i” tab • Prerequisites . v5r4 and: • http://files.zend.com/help/Zend-Server- IBMi/i5_installing_zend_server.htm • IBM’s FastCGI PTF (free) • Try Zend Studio’s IDE (no charge, courtesy of IBM) . “Zend Studio for Eclipse, IBM i Edition” . http://zend.com/en/products/studio/downloads . Look for “IBM i Edition” Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 13 Administration • Zend Server combines “Core” and “Platform” controls in one interface • Simpler Apache setup . Single web server • PASE server eliminated . IBM HTTP Server Powered by Apache • PHP implemented using IBM’s Fast CGI . Clean, more complete graphical user interface • Favorite: the Restart button Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 14 Admin menu (GO ZENDSVR/ZSMENU) Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 15 Zend Server’s Interface Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 16 Cheat sheet for upgrade http://alanseiden.com/2010/04/21/differences- between-zend-core-and-zend-server-on-ibm-i/ Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 17 Zend Server and PHP resources • Support: Zend Server CE includes one year of email support. Upgrade to Zend Server PE for more years and fast phone support . Register at http://www.zend.com/products/server/downloads and also get Zend’s IBM i newsletter • Web: . Zend’s recorded webinars: http://www.zend.com/resources/webinars/i5-os . Zend Forums: forums.zend.com (look for IBM i Zend Server forums) . http://alanseiden.com (of course!) • Books (online and print) . PHP Manual: http://php.net . PHP on IBM i book by Jeff Olen & Kevin Schroeder (MC Press) • Training from Zend/others Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 18 Community PHP resources • PHP User Groups . See http://php.net for a list . Not only learn, but tell the PHP world about IBM i • Conferences . COMMON Fall Conference (Congratulations—you made it!) . Zend/PHP (ZendCon), Nov 1-4, 2010, Santa Clara, Calif. • Your local IBM i / Power Systems user group . Consider asking your board to schedule some PHP talks . PHP topics tend to boost attendance Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 19 PHPPHP basicsbasics onon ii Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 20 PHP basics: Step 1 • Learn some basic HTML . Try http://w3schools.com/html . Tables (<table>,<tr>,<td>) useful for business data . “View Source” in browser to borrow bits of HTML • Then learn these as you go . Javascript • Adds dynamic functionality to pages . Cascading style sheets (CSS) • Modern way to specify colors, fonts, and other attibutes of how a site looks Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 21 Step 2: Try a simple PHP script • PHP scripts are text files that reside in the IFS • Edit using notepad or Zend Studio for Eclipse, IBM i edition • Script file: /www/zendsvr/htdocs/helloworld.php • Run in browser: http://yourIBMi:10088/helloworld.php <?php // simple script to test PHP echo “Hello, world!”; ?> Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 22 “Hello, world!” in browser Output from helloworld.php Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 23 Step 3: Access db2 Example: Code: /www/zendsvr/htdocs/Samples/SQL_access/DB2_SQL_example.php URL: http://yourIBMi:10088/Samples/SQL_access/DB2_SQL_example.php . Connect to db2 on i . Select records from a db2 table . Output the records into an HTML table Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 24 Step 4: Call RPG/CL from PHP Two methods: • i5 PHP Toolkit . included with Zend Server . call commands and programs . access data areas, spool files and other resources . Remote IBM i systems/LPARs can be accessed if you request a free license from Aura Easycom • http://www.easycom-aura.com/en/services_reg.asp • db2 Stored Procedures . “Native” way to call RPG/CL . Flexible: add SQL or multiple program calls in one s.p. Remote IBM i systems/LPARs can be accessed using ordinary DRDA- type connections. Supply an entry from WRKRDBDIRE Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 25 Let’s call this CL using both methods 0001.00 /* MYLIB/MYPGM, type CLLE */ 0002.00 0003.00 PGM PARM(&CODE &FNAME) 0004.00 DCL VAR(&CODE) TYPE(*DEC) LEN(5) 0005.00 DCL VAR(&FNAME) TYPE(*CHAR) LEN(10) 0005.01 0005.02 CHGVAR VAR(&CODE) VALUE(6) 0008.00 CHGVAR VAR(&FNAME) VALUE('JOHN') 0009.02 0010.00 ENDPGM Alan Seiden, Strategic Business Systems 5250 to Web: PHP Case Study on IBM i | | 26 First method: i5 Toolkit • Special “i5_” functions let PHP access system resources . call commands and programs .