Your SlideShare is downloading. ×
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Why PHP on IBM i
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Why PHP on IBM i

881

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
881
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • PASE – Portable Application Solutions Environment Starting in February of this year all IBM i’s come pre-loaded with Zend Core
  • Significant websites are built on PHP include: Facebook , [36] Wikipedia ( MediaWiki ), [37] Yahoo! , [38] and YouTube , Over 20 million websites use PHP – per Netcraft research data company in England. You can find PHP extensions for FTP, PDF, security, XML and Web services such as JSON (JavaScript Object Notation) at pecl.php.net.
  • Zend Core for i5/OS is a PHP extension/Add-on developed by Zend and IBM. It provides IBM i specific functionality in PHP. Native Command example: RTVJOBA, SBMJOB, CRTPF, etc… Allows you to leverage your existing code Zend was good enough to provide sample code showing how to use these functions. Check out the demo_for_toolkit_classes.php and toolkit_classes.php.
  • Open source apps: SugarCRM, MediaWiki (wikipedia), and phpMyAdmin. Overhead example: WAS – Websphere application server
  • Other PHP IDEs: Zend Studio (free for IBM i), Komodo, Eclipse (the only free software other than Studio for i), and PHPEdit. Learn HTML. There’s no way to avoid this.
  • Reiterate uppercase field names
  • Require, require_once, include, and include_once mention warning vs error Ask if there are any questions.
  • Transcript

    • 1. Why PHP on IBM i Why, where and how you can and should use PHP on IBM i
    • 2. Who is Jeff Olen and why should we listen to him?
      • IBM i developer for 20+ years
      • Vice-President and Co-founder of Olen Business Consulting, Inc.
      • Author of “IBM i Programmers Guide to PHP”
    • 3. PHP on IBM i - History
      • As of V5R2 (approx. 2003), IBM i developers have had the ability to compile and run PHP and MySQL in the PASE environment.
      • April 2006 – IBM selects Zend to bring PHP to the IBM i and announces that it will port PHP development tools (Core, Platform and Framework) to IBM i.
      • February 2009 – New IBM i shipments come preloaded with Zend Core PHP.
    • 4. Why PHP on IBM i?
      • Easy to make the transition from RPG to PHP.
      • Do not need to know object-oriented techniques.
      • Most popular web development language.
      • Huge open source community with vast amount of sample code and documentation.
      • Affordability (Did we mention that Zend Core and Zend Studio for i5/OS are free?)
      • Extensions for most common applications.
      • Many more…
    • 5. Zend Core for i5/OS
      • Allows PHP applications to access:
      • DB2 using RPG-like database access functions
      • Native RPG, Cobol, C and CL program calls
      • Native commands
      • Spool files
      • Data areas
      • User spaces
      • System values
      • Data queues
      • Message queues
      • Job Logs
    • 6. Value-Add for IBM i
      • By running PHP applications on the IBM i you gain the security, stability and reliability that the IBM i is known for.
      • Quickly and easily implement new applications.
        • Open Source applications
        • Existing sample code
      • Leverage existing business logic. For example RPG & Cobol programs.
      • Cost effective web solution (did we mention its free?)
      • Does not add overhead like some other solutions.
    • 7. Access IBM i DB2 tables with PHP
      • IBM DB2 functions
        • Completely system independent
      • Zend Toolkit Class library – Native File access i5_xxxx
        • Provides ready access to IBM i DB2 tables
        • Eases transition from RPG to PHP
      • MySQL IBMDB2i storage engine
        • Allows for quickly porting open source applications to DB2 database.
        • Provides an easy way to prototype IBM i PHP applications without access to an IBM i.
    • 8. How to start
      • Install Zend Core and/or Zend Platform on your IBM i (Check, it might already be there.)
      • Start the Zend Core Subsystem and Apache Servers.
      • Install Zend Studio (or another IDE) on a Windows client.
      • Get on the internet and download some open source examples and/or simple applications.
      • Save the sample code in the htdocs directory on your IBM i.
      • Open a browser and enter the URL.
      • That’s it!
    • 9. Questions?
    • 10. IBM i DB2 sample
      • <?php
      • // Set the database name.
      • // This is an IBM i System table (it exists on all IBM i machines)
      • $tableName = 'SYSTABLES';
      • $libName = 'QSYS2';
      • // create the connection to the IBM i relational database
      • if (!$dbh = db2_connect(“localhost&quot;,“jolen&quot;,“pass123&quot;)) {
      • echo &quot;connection failed.<br>&quot;;
      • echo db2_conn_errormsg() . &quot;<br>&quot;;
      • die();
      • }
      • // Retrieve a resultset of the column info for the specified table
      • if (!$cols = db2_columns( $dbh, null, $libName, $tableName, '%' )) {
      • echo &quot;columns retrieval failed.<br>&quot;;
      • echo db2_stmt_errormsg() . &quot;<br>&quot;;
      • die();
      • }
      • // output the Library and name of the table
      • $column = db2_fetch_assoc($cols);
      • echo &quot;Table: &quot;;
      • echo $column[&quot;TABLE_SCHEM&quot;].&quot;/&quot;.$column[&quot;TABLE_NAME&quot;].&quot;<br>&quot;;
      • // output all the column names
      • do {
      • echo $column[&quot;COLUMN_NAME&quot;].&quot;<br>&quot;;
      • } while ($column = db2_fetch_assoc($cols));
      • db2_close($dbh);
      • ?>
    • 11. IBM i DB2 sample output
    • 12. IBM DB2 Function sample
      • Source name: displayColumns.php
      • <?php
      • function displayColumns( $libraryName, $tableName ) {
      • if (!isset($dbh)) {
      • $dbh = db2_connect(&quot;localhost&quot;, &quot;jolen&quot;, &quot;pass123&quot;);
      • if (!$dbh) {
      • echo &quot;connection failed.<br>&quot;;
      • echo db2_conn_errormsg() . &quot;<br>&quot;;
      • die();
      • }
      • }
      • // retrieve a result set with the column info for the
      • // file specified at the top of the script.
      • if (!$cols = db2_columns( $dbh, null, $libraryName, $tableName, '%' )) {
      • echo &quot;columns retrieval failed.<br>&quot;;
      • echo db2_stmt_errormsg() . &quot;<br>&quot;;
      • die();
      • }
      • // Fetch the first row and output the file name and library name from the result set.
      • $column = db2_fetch_assoc($cols);
      • echo &quot;Table: &quot;;
      • echo $column[&quot;TABLE_SCHEM&quot;].&quot;/&quot;.$column[&quot;TABLE_NAME&quot;].&quot;<br>&quot;;
      • // loop thru all the result set rows and list all the column names.
      • do {
      • echo $column[&quot;COLUMN_NAME&quot;].&quot;<br>&quot;;
      • } while ($column = db2_fetch_assoc($cols));
      • }
    • 13. IBM DB2 Function sample
      • <?php
      • require_once(‘displayColumns.php');
      • displayColumns( 'QSYS2', 'SYSTABLES' );
      • echo &quot;<br><br>&quot;;
      • displayColumns( 'QSYS2', 'SYSROUTINES' );
      • ?>
    • 14. IBM DB2 Class example
      • Source name: fileinfo.class.php
      • <?php
      • class tableInfo {
      • var $columns;
      • var $table;
      • var $library;
      • var $dbh;
      • function __construct( $libraryName, $tableName ) {
      • if (!isset($this->dbh)) {
      • $this->dbh = db2_connect(&quot;localhost&quot;, &quot;jolen&quot;, &quot;pass123&quot;);
      • if (!$this->dbh) {
      • echo &quot;connection failed.<br>&quot;;
      • echo db2_conn_errormsg() . &quot;<br>&quot;;
      • die();
      • }
      • }
      • $this->library = $libraryName;
      • $this->table = $tableName;
      • }
    • 15.
      • // retrieve a result set with the column info for the file specified at the top of the script .
      • function retrieveColumnInfo() {
      • if (!$this->columns = db2_columns( $this->dbh, null, $this->library, $this->table, '%' )) {
      • echo &quot;columns retrieval failed.<br>&quot;;
      • echo db2_stmt_errormsg() . &quot;<br>&quot;;
      • die();
      • }
      • } // end of function
      • // retrieve a result set with the column info for the file specified at the top of the script .
      • function displayColumnInfo () {
      • echo &quot;Table: &quot;;
      • echo $this->library.&quot;/&quot;.$this->table.&quot;<br>&quot;;
      • $firstpass = TRUE;
      • while ($column = db2_fetch_assoc($this->columns)) {
      • if ($firstpass) {
      • $firstpass = FALSE;
      • echo &quot;<table border=1><tr>&quot;;
      • foreach ($column as $key => $value) {
      • echo &quot;<th>&quot;.$key.&quot;</th>&quot;;
      • }
      • echo &quot;</tr>&quot;;
      • }
      • echo &quot;<tr>&quot;;
      • foreach ($column as $value) {
      • echo &quot;<td>&quot;.$value.&quot;</td>&quot;;
      • }
      • echo &quot;</tr>&quot;;
      • }
      • echo &quot;</table>&quot;;
      • } // end of function
      • } // end of class code
      IBM DB2 Class example Continued
    • 16.
      • <?php
      • require_once(‘fileinfo.class.php');
      • $sysTables = new tableInfo('QSYS2','SYSTABLES');
      • $sysRoutines = new tableInfo('QSYS2','SYSROUTINES');
      • $sysRoutines->retrieveColumnInfo();
      • $sysRoutines->displayColumnInfo();
      • $sysTables->retrieveColumnInfo();
      • $sysTables->displayColumnInfo();
      • ?>
      IBM DB2 Class example
    • 17. Questions?
    • 18. Important Links
      • IBMDB2i storage engine install and docs:
      • http://solutions.mysql.com/engines/ibm_db2_storage_engine.html
      • IBM Redbook on IBMDB2i:
      • http://www.redbooks.ibm.com/abstracts/sg247705.html?Open
      • PHP Extensions
      • http://pecl.php.net
      • IBMDB2 documentation
      • http://www.php.net/ibm_db2
      • Subversion source control
      • http://subversion.tigris.org
      • Subclipse – subversion Eclipse Team Provider plug-in (works with RDi/WDSc)
      • http://subclipse.tigris.org
    • 19. OPC – Other People’s Code Hotscripts.com – “The nets largest script collection portal” phpClasses.org – PHP classes repository SourceForge.net – Find and develop open-source software
    • 20. Next steps
      • Training
        • Zend training classes
        • Olen Business Consulting, Inc. training (insert shameless sales pitch here)
        • Personalized training on-site
      • Source control/Version control
        • Subversion can be installed on IBM i
        • Subclipse plug-in works with WDSc/RDi
      • Database abstraction
        • DAO, VO and PDO
        • OO Classes
      • Object-oriented coding
        • Not necessary to begin using PHP
        • You will rapidly see the advantages once you get comfortable with PHP
      • Zend Framework and Zend Platform
      • Certification
    • 21. Questions?

    ×