php on ibm i tutorial

82
IBM i Tutorial By Mike Pavlak – Solution Consultant

Upload: zendcon

Post on 12-May-2015

7.638 views

Category:

Technology


5 download

DESCRIPTION

Talk by Mike Pavlak of Zend, at ZendCon 2009

TRANSCRIPT

Page 1: PHP on IBM i Tutorial

IBM i Tutorial

By Mike Pavlak – Solution Consultant

Page 2: PHP on IBM i Tutorial

2

IntroductionsWho do we have here?

Page 3: PHP on IBM i Tutorial

3

Who is Mike?

Solution Consultant: Techie tagalong – Works w/Account Managers

Help account managers develop solutions for customers

IBM i advocate COMMON Americas Advisory Council

Omni User Group

IT Director, Development manager, Consultant, Programmer, Ops…

IBM i PHP Bigot!

Page 4: PHP on IBM i Tutorial

4

Who are you?

• Around the room Name

Job Title

Company

What are you doing with PHP on IBM i?

Page 5: PHP on IBM i Tutorial

5

ZendCon ‘09 – IBM i Events

• Sessions on Tuesday PHP Faster and Cheaper

• Sam Hennessy – Zend Technologies

Zend Core on IBM i – Security Considerations• Tony Cairns – IBM

PHP and IBM i - Database Alternatives• Erwin Early – IBM

Zend Framework on IBM i• Alan Seiden – Strategic Business Systems

Mazda: Advanced Web Services and PHP• Olivier Lépine - Quatrain Technologies

Page 6: PHP on IBM i Tutorial

6

ZendCon ‘09 – IBM i Events (cont.)

Lunch• Tables will be labeled for i5 community networking

• Yes you can sit somewhere else

IBM i Networking Reception • Immediately following the “Meet the Team”

• Wednesday evening meet in the hall and head out

• Dinner is on you, but beers are on Zend!

• Gordon Biersch (note in your bag or see me!)

Page 7: PHP on IBM i Tutorial

7

Review IBM i Product Line from Zend

• Zend Core (PHP Runtime) Still free

Silver support for one year after Feb 2009

• Zend Studio 7.0 for IBM i (IDE) Still free

Basic support for one year after Feb 2009

• Zend Platform (Box of tools) Annual subscription license

• Support upgrades available (Throat to choke!) Gold and Platinum

Page 8: PHP on IBM i Tutorial

8

What’s new?

• Zend Server for IBM i New product that combines features from Core and

Platform

Single stack for all features

Alignment with other platforms!

One Apache server, not two! IBM server stays PASE server goes.

Still free version for i5 customers (Community Edition)

Currently in QA, beta soon GA after that

Page 9: PHP on IBM i Tutorial

9

Current Architecture

Zend CoreHTML + PHP

HTTP:89Server

(Reverse Proxy)

Request

Response

System i5

i5/OS

DB2 UDB

HTTP:8000Server

PHP file

PASE

PHPModule

URL: http://myproxy:89/core/registration.php

Zend Platform

Page 10: PHP on IBM i Tutorial

10

Agenda

• Toolkit functions

• Studio Integration Break #1

• Zend Server

• Open Source on IBM i Break #2

• Mix & Match Procedural PHP and Zend Framework

Page 11: PHP on IBM i Tutorial

11

Toolkit functionsHow we talk to IBM i from PHP Scripts

Page 12: PHP on IBM i Tutorial

12

Toolkit functions to be reviewed

• Differences between connections

• System Values

• Data Area

• Library List

• Object Listing

• Program Call

Page 13: PHP on IBM i Tutorial

13

Survey question

• How many folks have used i5 functions?

• Which ones?

• What are we missing?

Page 14: PHP on IBM i Tutorial

14

Connections, what’s the diff?

• i5_connect Access OS features

Access database features

Only available on i5, sorry Linux

• db2_connect Access database features only

Better performance

Great for ubiquitous development

Page 15: PHP on IBM i Tutorial

15

Connection successful

Page 16: PHP on IBM i Tutorial

16

Connection error

Page 17: PHP on IBM i Tutorial

17

DB2 Connection

• Get doc at http://php.net/manual/en/book.ibm-db2.php

Page 18: PHP on IBM i Tutorial

18

DB2 Connection

• i5 options listed here too!

Page 19: PHP on IBM i Tutorial

19

DB2 Connection: Good

Page 20: PHP on IBM i Tutorial

20

DB2 Connection: Bad

Page 21: PHP on IBM i Tutorial

21

System value

• Build a “Manager Shortcut” menu

• Key pieces of info for software installation & BP’s

• Display via browser

Page 22: PHP on IBM i Tutorial

22

System Value Code

Page 23: PHP on IBM i Tutorial

23

System Value Display

Page 24: PHP on IBM i Tutorial

24

Data Area

Use i5 to connect to IBM i

DB2 Connect will only take you to the Database

Page 25: PHP on IBM i Tutorial

25

Data Area Access

Page 26: PHP on IBM i Tutorial

26

Library List…

• I5_connect

• Get the data area without a library reference

Page 27: PHP on IBM i Tutorial

27

Data Area with library list

Page 28: PHP on IBM i Tutorial

28

Object Listing

• Given a library

• Show objects in the library

• Think of the list of objects as a result set from SQL

• Standard aproach Create list

Read list

This works for spooled files, active jobs, etc.

Page 29: PHP on IBM i Tutorial

29

Object listing code

Page 30: PHP on IBM i Tutorial

30

Object list output

Page 31: PHP on IBM i Tutorial

31

A brief word about CSS

• Cascading Style Sheets

• Very powerful in maintaining consistent look and feel of elements across applications

• Will continue to use sample.css through presentation

Page 32: PHP on IBM i Tutorial

32

Studio IntegrationHow Zend Platform works…

Page 33: PHP on IBM i Tutorial

33

Debugging for the rest of us…

• Very few slides

• Lots of demo Debug

Platform

More…

Page 34: PHP on IBM i Tutorial

34

Debug rules

• Must use port 8000!

• Tunnel helps a LOT

• Browser integration

• We’ll look at configuring debug in Zend Studio

• Then look at Zend Platform integration!

Page 35: PHP on IBM i Tutorial

35

Break Be back in 10 minutes

Page 36: PHP on IBM i Tutorial

36

Zend Server for IBM iThe next generation of the Zend Stack for IBM i

Page 37: PHP on IBM i Tutorial

37

The next generation of IBM i Zend Stack

• Improvements: Faster, How fast? I can’t tell you…but it is faster!

One less Apache server (Yay!)

More powerful JOBQ function

Alignment with the other product lines

Lot’s of tweaks and enhancements

• Private Beta starting soon

• Public beta immediately afterward

Page 38: PHP on IBM i Tutorial

38

Open Source on IBM iA quick look at PHPMyAdmin

Page 39: PHP on IBM i Tutorial

39

Number 2 reason folks look at PHP on IBM i

• Agenda Explore benefits of open source on IBM i

Ponder a short list of popular applications

Examine the components for installation

Review the installation steps

Walk through a live implementation

Page 40: PHP on IBM i Tutorial

40

phpMyAdmin

• Fabulous utility for accessing MySQL Data on ANY platform

• Written completely in PHP

• You must have MySQL installed

• Runs on IBM i…but…

• …not supported on IBM i

• DBU for MySQL!

Page 41: PHP on IBM i Tutorial

41

What we will do with phpMyAdmin

• Demo the product

• Walk through the install steps

• Demo a live installation

Page 42: PHP on IBM i Tutorial

42

phpMyAdmin

• Demo… http://cuper1.zend.com:89/phpmyadmin

Tour MIKEY1• Create table

• More features

Page 43: PHP on IBM i Tutorial

43

phpMyAdmin – Installation process

• Pre-requisties: Zend Core for i5/OS

MySQL version 5 or greater

V5R4 or V6R1

• Agenda Get file

Move to IBM i

Un-tar

Configure

Play

Page 44: PHP on IBM i Tutorial

44

Get phpMyAdmin file to IBM i

• Go to the host website, download current version http://www.phpmyadmin.net

Click Download at top of screen

Select version appropriate for you, I chose English tar.gz

Page 45: PHP on IBM i Tutorial

45

Compression

• Compression and archive…

• TAR was done first

• Then GZIP was done. So….

• You need to work in reverse Unzip the file on your workstation (PKZip, etc.)

Move the file phpMyAdmin-3.2.2-english.tar to the IFS doc root

Then untar on the i5

Page 46: PHP on IBM i Tutorial

46

Place file into document root

Page 47: PHP on IBM i Tutorial

47

Command to untar

• Tar = Tap Archive

• Use QP2TERM interfac to untar Call QP2TERM

• Change to the document root CD /www/zendcore/htdocs

Page 48: PHP on IBM i Tutorial

48

Open PASE Shell

Page 49: PHP on IBM i Tutorial

49

Open PASE Shell

Page 50: PHP on IBM i Tutorial

50

After the tar

• The screen will roll quite a bit then you get the $

• Now create a symbolic link to the directory for ease of use ln -s ./phpMyAdmin-3.2.2-english phpMyAdmin

Page 51: PHP on IBM i Tutorial

51

Create the config file

• The config file tells phpMyAdmin where everything is. Create manually

Use automated feature

• Move to the phpMyAdmin directory cd phpmyadmin

• Create the directory & set security mkdir config

chmod o+rw config

Page 52: PHP on IBM i Tutorial

52

Results of directory and security changes

Page 53: PHP on IBM i Tutorial

53

Go to browser to run config

• http://your_host/path/to/phpMyAdmin/setup/

Page 54: PHP on IBM i Tutorial

54

Scroll down to config options

• Click the New server button…

Page 55: PHP on IBM i Tutorial

55

Enter server specific info

• Type a description of the server name

• Leave localhost for hostname…click SAVE

Page 56: PHP on IBM i Tutorial

56

Finish options

• Select language, etc. And click save again

Page 57: PHP on IBM i Tutorial

57

Copy the config file to phpMyAdmin directory

• You just created a config file in directory config

• Move the file to the phpMyAdmin directory for use mv config/config.inc.php .

chmod o-rw config.inc.php

Page 58: PHP on IBM i Tutorial

58

Head to the phpMyAdmin login screen

• http://yourservername/phpMyAdmin/

Page 59: PHP on IBM i Tutorial

59

Add user to MySQL

• cd /usr/local/mysql/bin

• Mysql –u root

• use mysql select user, password from user;

Page 60: PHP on IBM i Tutorial

60

Before the addition

Page 61: PHP on IBM i Tutorial

61

After the addition

• Add the user: CREATE USER ‘mpavlak'@‘%' IDENTIFIED BY ‘test1';

GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO ‘mpavlak'@’%’;• Or

GRANT ALL ON *.* TO ‘mpavlak'@’%’;

Page 62: PHP on IBM i Tutorial

62

And we’re in!

Page 63: PHP on IBM i Tutorial

63

Break Be back in 10 minutes

Page 64: PHP on IBM i Tutorial

64

Mix & matchProcedural PHP & Zend Framework

Page 65: PHP on IBM i Tutorial

65

Procedural PHP and Zend Framework

• Agenda Look at a procedural PHP application that gets order info

Look at the info in a web page

Move info to PDF and distribute

Think ZF is hard? Guess again!

Page 66: PHP on IBM i Tutorial

66

Zend_PDF

• Check out the Zend Framework website http://www.zendframework.com/manual/en/zend.pdf.html

• Look at an example that reads DB2 data and produces a PDF

Page 67: PHP on IBM i Tutorial

67

Agenda

• Read order detail file

• Instantiate a PDF object

• Update the object with the contents of the order

• Write the PDF

• Dispose of the object

• Admire our work!

Page 68: PHP on IBM i Tutorial

68

Zend_PDF

• Component of Zend Framework

• Comes with Zend Core for i5

• FREE!!!

• ZF is built by the community, for the community

• Documentation at: http://framework.zend.com/manual/en/zend.pdf.html

Page 69: PHP on IBM i Tutorial

69

Build the content

• Read through the detail file…

Page 70: PHP on IBM i Tutorial

70

Object & heading

• Create object

• Set heading

Page 71: PHP on IBM i Tutorial

71

Body of print

• Develop line detail

• Output the PDF o the IFS

Page 72: PHP on IBM i Tutorial

72

Windows Explorer view of IFS

• Once in the IFS you do what you want FTP, email, cms, etc…

Page 73: PHP on IBM i Tutorial

73

The PDF!

Page 74: PHP on IBM i Tutorial

74

Zend_PDF Documentation

• Check out Zend_PDF doc at ZendFramework.com Make it look pretty

Integrate into procedural development

Learn a little OO as you go

• Come to Zend for more training Higher Structures

Zend Framework

Certification prep

More…

Page 75: PHP on IBM i Tutorial

75

Where to get more informationZend and other places

Page 76: PHP on IBM i Tutorial

76

Free code!

• PHPClasses.org

• Hotscript.com

• Sourceforge.net

• Php.net

• Thefreecountry.com/php

Page 77: PHP on IBM i Tutorial

77

Support

• Zend.com Forums

Knowledgebase

Webcasts

Downloads

Developer Zone

Product information & documentation

Paid products

Page 78: PHP on IBM i Tutorial

78

New book, new printing, same great stuff!

Kevin Schroeder from Zend’s Global Services

Group

with

Jeff Olen, co-author of…

Get yours at MCPressonline

or at fine bookstores everywhere

Page 79: PHP on IBM i Tutorial

79

Mike’s blog!

• http://mikepavlak/blogspot.com

• Aggregated at http://planet-i.org/

Page 80: PHP on IBM i Tutorial

80

IBM i Events…reminder!!!

• Sessions on Tuesday PHP Faster and Cheaper

• Sam Hennessy – Zend Technologies

Zend Core on IBM i – Security Considerations• Tony Cairns – IBM

PHP and IBM i - Database Alternatives• Erwin Early – IBM

Zend Framework on IBM i• Alan Seiden – Strategic Business Systems

Mazda: Advanced Web Services and PHP• Olivier Lépine - Quatrain Technologies

Page 81: PHP on IBM i Tutorial

81

IBM i Events (cont.)

Lunch• Tables will be labeled for i5 community networking

• Yes you can sit somewhere else

IBM i Networking Reception • Immediately following the “Meet the Team”

• Wednesday evening meet in the hall and head out

• Dinner is on you, but beers are on Zend!

• Gordon Biersch (note in your bag or see me!)

Page 82: PHP on IBM i Tutorial

82

Please enjoy the Conference!Thank you!!!