Integrating PHP with System i using Web Services June, 2007 Sam Pinkhasov Ivo Jansch
May 06, 2015
Integrating PHP with System i using Web Services
June, 2007
Sam PinkhasovIvo Jansch
# 2
Agenda
• PHP overview• PHP products for i5/OS• How to create a Web Service wrapper for an RPG
program • Q&A
# 3
What is PHP? • PHP is an easy to use, open source,
platform independent scripting language Designed for web application development 4.5+ Million PHP Developers
• PHP is the leading scripting language deployed on the Internet 22+ Million Internet domains Out Pacing Microsoft’s ASP*
• Thousands of PHP applications are available Web applications tied to databases Content management Wikis and Blogs
www.sourceforge.org
www.hotscripts.com,
www.phpjunkyard.com/
www.phpfreaks.com/
www.phpfreebies.com/ * Source: 2005 Netcraft Survey http://www.php.net/usage.php
# 4
Drivers for PHP growth
• The Migration to Web Applications When did you last install a desktop application? Emerging generation of software services (Web2.0) Web becoming the new UI to existing backend applications
• PHP is the perfect Web Integration Platform Perfect front-end glue language Best support for browser based rich client applications (Ajax) Strong support for Web Services, XML & legacy systems Powerful SOA capabilities enable new IT approaches (“mashable assets”)
for reducing application backlogs• PHP is backed by a very strong community
Very easy to learn and adopt ~ 1000 committers, ~ 4.5M developers (corporate/community) Thousands of opensource projects and applications Hundreds of thousands of commercial deployments
# 5
How does PHP work?
1. Browser requests a Web page (HTML) from the Web server.2. The user enters data or performs an action.3. The browser sends a request for a PHP file to the Web server.4. The Web server forwards the PHP file to the PHP engine5. The PHP engine processes the PHP code, optionally accessing
server resources (such as a database) or performing calculations.6. The PHP engine replaces the PHP code with the results of its
processing7. The result (all HTML code) is sent to the Web server.8. The Web server sends the result as a response to the browser9. The browser loads the response code.
# 6
PHP Example
<html>
<head><title>Test Page</title></head>
<p>
<?php
echo “This is my PHP test page”
?>
</p>
</html>
<html>
<head><title>Test page></title></head>
<p>
This is my php test page
</p>
</html>
PH
P Code
Original HTML HTML Processed by PHP Engine
# 7
Why use PHP?
• Easy to learn with a large support community
• Most popular server side language on the Web
• Thousands of free PHP applications are available
• Fairly lightweight runtime environment Easy to administer (Zend provides tools)
• Provides many extensions for particular programming tasks Database APIs (DB2, MySQL, Oracle, SQLServer, etc.) i5 PHP Toolkit (only available with Zend Core or Zend Platform) XML PDF Cryptography Web services
# 8
Why Do Developers Use PHP?
Zend's June 2003 market snapshot of the PHP community. The survey had over 10,000 respondents. http://www.zend.com/zend/php_survey_results.php
# 9
What Types of Applications in PHP?
Zend's June 2003 market snapshot of the PHP community. The survey had over 10,000 respondents. http://www.zend.com/zend/php_survey_results.php
# 10
Zend Technologies
• The founders of Zend have been key contributors to the PHP language since 1997
• Zend delivers commercial products that enable developers and IT personnel to deliver and operate business-critical PHP applications
Zend has been the leading supplier of PHP products and solutions for the last six years. Its products and solutions are being used by more than 15,000 companies worldwide. The Zend Engine (the PHP kernel) is being utilized on more than 22 million websites today
Zend takes the open source PHP code through rigorous testing for additional quality assurance and adds over 35 popular PHP extensions to deliver their PHP runtime environment
• Zend provides enterprise level support for the PHP environment
# 11
What are System i Customer’s Doing with PHP?
– Consolidation: Move PHP applications that are running on Windows or Linux that access data in DB2 to run in i5/OS to speed up or reduce complexity of the applications.
– Modernization: Use PHP to web-enable green screen applications.
– New application development: Create new applications with PHP on i5/OS including applications for the intranet, reporting, websites, and extranets.
– Leveraging PHP portfolio: Run commercial or opensource PHP applications on i5/OS.
# 12
• Zend Core for i5/OS (Free)A fully tested and enhanced version of the open source PHP runtime
environement.
• Zend Platform for i5/OS (Chargeable)A robust PHP production environment providing performance, scalability, and
monitoring for PHP applications
• Zend Guard (Chargeable)Provides code protection and license mgmt tools for solution providers
• Zend Studio for i5/OS (Free)Provides an integrated IDE for building and debugging PHP applications
Market – Products
• Services (Chargeable): Training and Pro Service
• Zend Support (Free & Chargeable)Free web-based support and chargeable premium support
Zend CoreTM
Certified and Supported PHP + Database Integration
# 14
Zend Core for i5/OS
• Zend Core is a distribution of PHP maintained through a partnership between IBM and Zend Native DB2/400 UDB/Cloudscape support Toolkit - Native access System i objects :
• Programs, Service programs(*SRVPGM) and CL commands• Spooled file, Data Queue, User Space, Job logs
WebEnabler Technology Zend Studio Server for remote debugging Everything you need to get started
• You can download Zend Core for free Contains everything you need to start building applications
(Apache web server, PHP 5.x.x and most common extensions)
# 15
PHP Environment After Installation
Zend CoreHTML + PHP
HTTP:89Server
(Reverse Proxy)
Request
Response
System i5
i5/OS
DB2 UDB
HTTP:8000Server
I5/OS
resources
PASE
PHPModule
URL: http://myproxy:89/core/registration.php
Zend Platform
# 16
Zend Core: DEMO
# 17
i5 Toolkit APIs• Are shipped with Zend products
Zend core for i5/OS
• Geared towards accessing i5 data and resources from PHP Similar in purpose to the IBM Tookbox for Java
# 18
i5 Toolkit APIs• Connection managementi5_connecti5_closei5_adopt_authorityi5_errori5_errnoi5_errormsg
• Command callsi5_command
• Program callsi5_program_preparei5_program_prepare_PCMLi5_program_calli5_program_close
• Data retrieval i5_fetch_array i5_fetch_assoc i5_fetch_object i5_fetch_row i5_info i5_field_len i5_field_name i5_field_scale i5_field_type i5_list_fields i5_num_fields i5_result
• Native file access i5_open i5_addnew I5_edit I5_delete i5_cancel_edit i5_setvalue i5_update i5_range_from i5_range_to i5_range_clear i5_data_seek i5_seek i5_bookmark i5_free_file i5_new_record i5_update_record i5_get_keys
# 19
i5 Toolkit APIs• System valuesi5_get_system_value
• Data areasi5_data_area_preparei5_data_area_receivei5_data_area_sendi5_data_area_close
•Print/Get spooled file i5_spool_listi5_spool_list_readi5_spool_list_closei5_spool_get_datai5_spool_from_file
• Job logsi5_jobLog_listi5_jobLog_list_readi5_jobLog_list_close
• Active jobsi5_job_listi5_job_list_readi5_job_list_close
• Objects listi5_object_listi5_object_list_readi5_object_list_close
• User spacei5_userspace_creartei5_userspace_preparei5_userspace_geti5_userspace_put
• Data Queuei5_dtaq_preparei5_dtaq_recievei5_dtaq_sendi5_dtaq-close
# 20
Demo Application – WRKACTJOB
# 21
Demo Application – WRKSPLF
# 22
Demo Application – WRKUSRPF
PHP DEVELOPMENT ENVIRONMENTS
The Most Complete Development Environment for
PHP
# 24
• Special, freely-available version for i5/OS servers
• The most productive development environment for PHP Highly advanced PHP editor Client/Server debugging & profiling Database integration Fully supports PHP 5 and the latest
technologies Runs on Windows, Linux, MAC Tightly integrated with the Zend
product line
Zend Studio Professional for i5/OS
# 25
Zend Studio DEMO
# 26
Zend Studio for i5/OS System Requirements
Supported Operating Systems, Platforms and OS versions:Windows x86 2000, XP, 2003 Linux x86 Linux x86-64 Mac OS X Power 10.4
•Zend Studio Client - PHP Compatibility:Supports all PHP versions
Zend Platform
Complete Web Production Management
# 28
Complete Web Production Management
Scalability & Integration
Performance Reliability
Zend Platform for i5/OS
Run-time Code Optimization
Code Acceleration and Pre-Compilation
Full Caching Solution Download Optimization
and Acceleration Benchmarking and Insight
Validation Performance Tuning
Central Hub-and-Spoke
Management Event Consolidation Centralized PHP
Configuration Job Queues Java Bridge Business Intelligence &
Reporting Tools (BIRT)
Proactive Monitoring, PHP Intelligence
Run-time Profiling and Performance Monitoring
Report and Track Run-time Issues
Audit trail (Error Re-creation and Full Problem Context
Online Debugging Web-based Management
# 29
PHP Production Environment Stack
# 30
Integration with Zend Studio provides direct access to the affected source code - Immediate Debugging & Profiling enables code problems to be
identified and fixed within seconds
Reliability - PHP IntelligenceFix Errors Immediately - Ensures full business availability
# 31
Integration - Java Bridge Java Bridge – Easy Integration
<?
$system = new Java("java.lang.System");
print $system."\n"; // will use toString in PHP5
print "Java version=".$system->getProperty("java.version")." <br>\n";
print "Java vendor=".$system->getProperty("java.vendor")." <p>\n\n";
print "OS=".$system->getProperty("os.name")." ".
$system->getProperty("os.version")." on ".
$system->getProperty("os.arch")." <br>\n";
?>
Integrating with Java is as simple as instantiating the object, and using it
Java objects are mapped to PHP objects
# 32
Integration - BIRT ReportingReporting Framework Integration
• Create graphical reports using Actuate API through PHP• Based on the
Eclipse Open Source Business Intelligence Reporting and Tools (BIRT) project
Zend Guard
# 34
• Encoding & Obfuscation Enables the PHP source code protection, against copyright infringement
and reverse-engineering, of commercial PHP applications Provides IT Managers with a solution that prohibits modification of their
internal PHP application source code so they can effectively support them• Licensing
Allows ISVs to impose a variety of licensing policies on commercial PHP applications
Vendors can increase their revenue by choosing from a variety of licensing models such as concurrent users, time limited, segment of network, server specific or i5/OS processing group
• Product Components Front End GUI Encoder CLI Zend Optimizer
Zend Guard for i5/OS
# 35
Zend Guard for i5/OS
# 36
Zend Platform
System i
DB2/400
Pgm, CMD,Spooled file
Database
Business
Zend StudioBrowser
Zend Core with Toolkit APIs
Apache webserver
Zend PHP Components for i5/OS
Zend Guard
Windows/Linux
Let’s create a Web Service for an RPG program
# 38
• Definition The W3C defines a Web service as a software system
designed to support interoperable machine-to-machine interaction over a network. Web services are frequently just application programming interfaces (API) that can be accessed over a network, such as the Internet, and executed on a remote system hosting the requested servicesg group
• A Web Service enables an application to expose what it does or what it knows so that other applications can make use of it. .
Web Services
# 39
• Web Services web site www.programmableweb.com • Lists more than 350 APIs• Web Services opens the door for software
applications written in different languages to be able to exchange data and services.
Web Services
# 40
• Web Service is not a trivial task• Knowledge of OOP, XML and SOAP. • Zend’s products shield developers from development
complexity• Demo:
Create Web Service using Zend’s tools that will wrap existing RPG program
Web Services
# 41
Web Services
0022.00 *************** 0023.00 C *ENTRY PLIST 0024.00 C PARM CODE 10 0025.00 C PARM NAME 10 0026.00 ********************** 0027.00 C CODE IFEQ '1' 0028.00 C movel 'IBM' name 0029.00 C ELSE 0030.00 C CODE IFEQ '2' 0031.00 C movel 'Zend' name 0032.00 C ELSE 0033.00 C movel 'wrong code' code 0034.00 C ENDIF 0035.00 C ENDIF 0036.00 C* 0037.00 C SETON LR 0038.00 C RETURN •
•
# 42
Web Services
# 43
Web Services
# 44
Web Services
# 45
Web Services
# 46
Web Services
# 47
Web Services
# 48
Zend DevZone
• Devzone.zend.com http://devzone.zend.com/node/view/id/1912
# 49
• Shortens the development cycle• Re-usability • Building blocks for SOA
Web Services Benefits
# 50
Zend for i5/OS Resources
• Monthly Newsletter - Email [email protected] to receive Zend i5/OS Newsletter
• Dutch PHP Zend partner WWW.IBUILDINGS.NL• PHP Tutorial http://php.net/manual/en/tutorial.php
• Zend forum for i5/OS http://www.zend.com/forums/index.php?t=index&cat=7
• IBM Redbooks: Building SOA-based Solutions for IBM System i5 Platform
http://www.redbooks.ibm.com/redpieces/abstracts/sg247284.html?Open
• IBM RedWiki PHP Zend for i5/OS http://www-941.haw.ibm.com/collaboration/ibmwiki/display/sg247327/Home
# 51
Zend for i5/OS Resources
• Check out the thousands of PHP scripts available that can be used as-is or as the starting point for Web projects. http://www.hotscripts.com http://www.phpjunkyard.com/ http://www.phpfreaks.com/ http://phpfreebies.com/
Q & A