php tips for ibm i in 60 mins

43
30+ PHP Tips in 60 Minutes Mike Pavlak, Solution Consultant [email protected] https://joind.in/talk/c127e

Upload: mpavlak

Post on 15-Jan-2017

202 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Php tips for IBM i in 60 mins

30+ PHP Tips in 60 MinutesMike Pavlak Solution Consultant

mikepzendcom

httpsjoindintalkc127e

2

Tip 1 ndash RTFM ndash phpnet

bull Donrsquot waste money on books that summarize functions

ndash Becomes out of date QUICKLY

ndash Online manual is free

ndash Books worth buying

bull Cookbooks

bull Design patterns

bull Advanced PHP etc

bull Open Source community ldquoassumesrdquo you have done this

ndash Good questions get answered quickly

ndash Stupid questions tend to get ignored or ridiculed

bull Install a browser you rarely use (like IE) and set initial page to phpnet

3

Tip 2 ndash Keep current

bull PHP is NOT RPG

ndash Only RPG supports 40 years of backward compatibility

bull PHP needs updating

ndash Security patches (www)

ndash New features

ndash Deprecated functions

bull Long Term Support comes to IBM i community FOR FREE

bull PHP is an ldquoedgerdquo technology and these require frequent updating

4

Tip 3 ndash Master Web Development

bull HTML 5

ndash The glue or DDS of the web

ndash Easy to start

bull Cascading Style Sheets

ndash Bring organization to site

ndash Powerful feature set (csszengardencom)

bull JavaScript

ndash Power browser functions

ndash Many good code libraries

bull jQuery

bull ExtJS-Sencha

bull Angular

5

Tip 4 ndash Develop with error reporting on

bull PHP is best suited for iterative development model

ndash Code Save Refresh Repeat

bull ALSO Find errors as you go at the script level

ndash error_reporting(-1) report all error levels

ndash ini_set(display_errors 1) show me the errors

bull Installation of Zend Server for Production turns this off

ndash COMMON for this to be off in single LPAR environments

ndash Get a developer LPAR (later)

bull Admin GUI

ndash PHPExtensions

6

Tip 5 ndash Get a Development LPAR

bull No more excuses

ndash IBM has made this MUCH easier (i on i)

ndash IBM has made this much less expensive

bull Couple thousand Disk RAM

bull Only one instance of Zend Server supported per LPAR

ndash Settings are global (phpini)

ndash Library list can be manipulated but isolation requires CHROOT etc

bull New PHP developers donrsquot get having dev amp prod on same LPAR

ndash ldquooff the streetrdquo struggle with one server let alone libl etchellip

ndash Can do dangerous things like issue ALTER TABLE to CUSTMAST

bull You are doing more with your IBM i now than ever before

ndash ldquoI never had a dev LPAR beforerdquo is not a valid excuse

ndash Give your devs the freedom to experiment

7

Tip 6 ndash Donrsquot write PHP like RPG

bull RPG applications often are built with main file then chains

ndash SETLL then READE ORDDETAIL

bull CHAIN PRODUCT

bull CHAIN INVENT

bull CHAIN ONPLAN

bull Consider a single SQL statement

ndash Join files are more efficient that chains in most cases

ndash SQL optimizers are genius

ndash Learn good indexing strategy

ndash Go to SQL sessions at conferences

ndash Ask Mike Cain hersquoll tell you

bull Great Redbooks

ndash Database modernization

ndash RPG and Application Modernization

8

Tip 7 ndash RTFM DB2

bull There is a wealth of information at phpnet

bull DB2 manual contains all functions for the DB2 extension

bull All of these can apply to PHP

ndash Column names counts

ndash Commitment control

ndash Prepared SQL (Good stuff)

bull httpphpnetmanualenbookibm-db2php

9

Tip 8 ndash Array creation shortcuts

bull PHP 54 introduced [ ]

ndash Old still supported $array1 = array(lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo)

ndash New method $array2 = [lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo]

ndash Implode explode

bull Arrays can also be constants in PHP7 Woohoo

10

Tip 9 ndash Performance of logs

bull PHP logfile captures EVERY PHP error (can be adjusted)

bull Most expensive thing you can do is readwrite to IFS

bull usrlocalzendsvr6varlogphplog

bull ldquocliprdquo the logfile periodically

ndash Rename or delete

ndash Add this to weeklymonthly CL process

ndash PHP just creates a new one when it needs it

Rod Says 1Rod Says 2

11

Tip 10 ndash Read PHP logs

bull Lots of good stuff there

bull Notice errors can be expensive

bull Deprecated functions

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 2: Php tips for IBM i in 60 mins

2

Tip 1 ndash RTFM ndash phpnet

bull Donrsquot waste money on books that summarize functions

ndash Becomes out of date QUICKLY

ndash Online manual is free

ndash Books worth buying

bull Cookbooks

bull Design patterns

bull Advanced PHP etc

bull Open Source community ldquoassumesrdquo you have done this

ndash Good questions get answered quickly

ndash Stupid questions tend to get ignored or ridiculed

bull Install a browser you rarely use (like IE) and set initial page to phpnet

3

Tip 2 ndash Keep current

bull PHP is NOT RPG

ndash Only RPG supports 40 years of backward compatibility

bull PHP needs updating

ndash Security patches (www)

ndash New features

ndash Deprecated functions

bull Long Term Support comes to IBM i community FOR FREE

bull PHP is an ldquoedgerdquo technology and these require frequent updating

4

Tip 3 ndash Master Web Development

bull HTML 5

ndash The glue or DDS of the web

ndash Easy to start

bull Cascading Style Sheets

ndash Bring organization to site

ndash Powerful feature set (csszengardencom)

bull JavaScript

ndash Power browser functions

ndash Many good code libraries

bull jQuery

bull ExtJS-Sencha

bull Angular

5

Tip 4 ndash Develop with error reporting on

bull PHP is best suited for iterative development model

ndash Code Save Refresh Repeat

bull ALSO Find errors as you go at the script level

ndash error_reporting(-1) report all error levels

ndash ini_set(display_errors 1) show me the errors

bull Installation of Zend Server for Production turns this off

ndash COMMON for this to be off in single LPAR environments

ndash Get a developer LPAR (later)

bull Admin GUI

ndash PHPExtensions

6

Tip 5 ndash Get a Development LPAR

bull No more excuses

ndash IBM has made this MUCH easier (i on i)

ndash IBM has made this much less expensive

bull Couple thousand Disk RAM

bull Only one instance of Zend Server supported per LPAR

ndash Settings are global (phpini)

ndash Library list can be manipulated but isolation requires CHROOT etc

bull New PHP developers donrsquot get having dev amp prod on same LPAR

ndash ldquooff the streetrdquo struggle with one server let alone libl etchellip

ndash Can do dangerous things like issue ALTER TABLE to CUSTMAST

bull You are doing more with your IBM i now than ever before

ndash ldquoI never had a dev LPAR beforerdquo is not a valid excuse

ndash Give your devs the freedom to experiment

7

Tip 6 ndash Donrsquot write PHP like RPG

bull RPG applications often are built with main file then chains

ndash SETLL then READE ORDDETAIL

bull CHAIN PRODUCT

bull CHAIN INVENT

bull CHAIN ONPLAN

bull Consider a single SQL statement

ndash Join files are more efficient that chains in most cases

ndash SQL optimizers are genius

ndash Learn good indexing strategy

ndash Go to SQL sessions at conferences

ndash Ask Mike Cain hersquoll tell you

bull Great Redbooks

ndash Database modernization

ndash RPG and Application Modernization

8

Tip 7 ndash RTFM DB2

bull There is a wealth of information at phpnet

bull DB2 manual contains all functions for the DB2 extension

bull All of these can apply to PHP

ndash Column names counts

ndash Commitment control

ndash Prepared SQL (Good stuff)

bull httpphpnetmanualenbookibm-db2php

9

Tip 8 ndash Array creation shortcuts

bull PHP 54 introduced [ ]

ndash Old still supported $array1 = array(lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo)

ndash New method $array2 = [lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo]

ndash Implode explode

bull Arrays can also be constants in PHP7 Woohoo

10

Tip 9 ndash Performance of logs

bull PHP logfile captures EVERY PHP error (can be adjusted)

bull Most expensive thing you can do is readwrite to IFS

bull usrlocalzendsvr6varlogphplog

bull ldquocliprdquo the logfile periodically

ndash Rename or delete

ndash Add this to weeklymonthly CL process

ndash PHP just creates a new one when it needs it

Rod Says 1Rod Says 2

11

Tip 10 ndash Read PHP logs

bull Lots of good stuff there

bull Notice errors can be expensive

bull Deprecated functions

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 3: Php tips for IBM i in 60 mins

3

Tip 2 ndash Keep current

bull PHP is NOT RPG

ndash Only RPG supports 40 years of backward compatibility

bull PHP needs updating

ndash Security patches (www)

ndash New features

ndash Deprecated functions

bull Long Term Support comes to IBM i community FOR FREE

bull PHP is an ldquoedgerdquo technology and these require frequent updating

4

Tip 3 ndash Master Web Development

bull HTML 5

ndash The glue or DDS of the web

ndash Easy to start

bull Cascading Style Sheets

ndash Bring organization to site

ndash Powerful feature set (csszengardencom)

bull JavaScript

ndash Power browser functions

ndash Many good code libraries

bull jQuery

bull ExtJS-Sencha

bull Angular

5

Tip 4 ndash Develop with error reporting on

bull PHP is best suited for iterative development model

ndash Code Save Refresh Repeat

bull ALSO Find errors as you go at the script level

ndash error_reporting(-1) report all error levels

ndash ini_set(display_errors 1) show me the errors

bull Installation of Zend Server for Production turns this off

ndash COMMON for this to be off in single LPAR environments

ndash Get a developer LPAR (later)

bull Admin GUI

ndash PHPExtensions

6

Tip 5 ndash Get a Development LPAR

bull No more excuses

ndash IBM has made this MUCH easier (i on i)

ndash IBM has made this much less expensive

bull Couple thousand Disk RAM

bull Only one instance of Zend Server supported per LPAR

ndash Settings are global (phpini)

ndash Library list can be manipulated but isolation requires CHROOT etc

bull New PHP developers donrsquot get having dev amp prod on same LPAR

ndash ldquooff the streetrdquo struggle with one server let alone libl etchellip

ndash Can do dangerous things like issue ALTER TABLE to CUSTMAST

bull You are doing more with your IBM i now than ever before

ndash ldquoI never had a dev LPAR beforerdquo is not a valid excuse

ndash Give your devs the freedom to experiment

7

Tip 6 ndash Donrsquot write PHP like RPG

bull RPG applications often are built with main file then chains

ndash SETLL then READE ORDDETAIL

bull CHAIN PRODUCT

bull CHAIN INVENT

bull CHAIN ONPLAN

bull Consider a single SQL statement

ndash Join files are more efficient that chains in most cases

ndash SQL optimizers are genius

ndash Learn good indexing strategy

ndash Go to SQL sessions at conferences

ndash Ask Mike Cain hersquoll tell you

bull Great Redbooks

ndash Database modernization

ndash RPG and Application Modernization

8

Tip 7 ndash RTFM DB2

bull There is a wealth of information at phpnet

bull DB2 manual contains all functions for the DB2 extension

bull All of these can apply to PHP

ndash Column names counts

ndash Commitment control

ndash Prepared SQL (Good stuff)

bull httpphpnetmanualenbookibm-db2php

9

Tip 8 ndash Array creation shortcuts

bull PHP 54 introduced [ ]

ndash Old still supported $array1 = array(lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo)

ndash New method $array2 = [lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo]

ndash Implode explode

bull Arrays can also be constants in PHP7 Woohoo

10

Tip 9 ndash Performance of logs

bull PHP logfile captures EVERY PHP error (can be adjusted)

bull Most expensive thing you can do is readwrite to IFS

bull usrlocalzendsvr6varlogphplog

bull ldquocliprdquo the logfile periodically

ndash Rename or delete

ndash Add this to weeklymonthly CL process

ndash PHP just creates a new one when it needs it

Rod Says 1Rod Says 2

11

Tip 10 ndash Read PHP logs

bull Lots of good stuff there

bull Notice errors can be expensive

bull Deprecated functions

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 4: Php tips for IBM i in 60 mins

4

Tip 3 ndash Master Web Development

bull HTML 5

ndash The glue or DDS of the web

ndash Easy to start

bull Cascading Style Sheets

ndash Bring organization to site

ndash Powerful feature set (csszengardencom)

bull JavaScript

ndash Power browser functions

ndash Many good code libraries

bull jQuery

bull ExtJS-Sencha

bull Angular

5

Tip 4 ndash Develop with error reporting on

bull PHP is best suited for iterative development model

ndash Code Save Refresh Repeat

bull ALSO Find errors as you go at the script level

ndash error_reporting(-1) report all error levels

ndash ini_set(display_errors 1) show me the errors

bull Installation of Zend Server for Production turns this off

ndash COMMON for this to be off in single LPAR environments

ndash Get a developer LPAR (later)

bull Admin GUI

ndash PHPExtensions

6

Tip 5 ndash Get a Development LPAR

bull No more excuses

ndash IBM has made this MUCH easier (i on i)

ndash IBM has made this much less expensive

bull Couple thousand Disk RAM

bull Only one instance of Zend Server supported per LPAR

ndash Settings are global (phpini)

ndash Library list can be manipulated but isolation requires CHROOT etc

bull New PHP developers donrsquot get having dev amp prod on same LPAR

ndash ldquooff the streetrdquo struggle with one server let alone libl etchellip

ndash Can do dangerous things like issue ALTER TABLE to CUSTMAST

bull You are doing more with your IBM i now than ever before

ndash ldquoI never had a dev LPAR beforerdquo is not a valid excuse

ndash Give your devs the freedom to experiment

7

Tip 6 ndash Donrsquot write PHP like RPG

bull RPG applications often are built with main file then chains

ndash SETLL then READE ORDDETAIL

bull CHAIN PRODUCT

bull CHAIN INVENT

bull CHAIN ONPLAN

bull Consider a single SQL statement

ndash Join files are more efficient that chains in most cases

ndash SQL optimizers are genius

ndash Learn good indexing strategy

ndash Go to SQL sessions at conferences

ndash Ask Mike Cain hersquoll tell you

bull Great Redbooks

ndash Database modernization

ndash RPG and Application Modernization

8

Tip 7 ndash RTFM DB2

bull There is a wealth of information at phpnet

bull DB2 manual contains all functions for the DB2 extension

bull All of these can apply to PHP

ndash Column names counts

ndash Commitment control

ndash Prepared SQL (Good stuff)

bull httpphpnetmanualenbookibm-db2php

9

Tip 8 ndash Array creation shortcuts

bull PHP 54 introduced [ ]

ndash Old still supported $array1 = array(lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo)

ndash New method $array2 = [lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo]

ndash Implode explode

bull Arrays can also be constants in PHP7 Woohoo

10

Tip 9 ndash Performance of logs

bull PHP logfile captures EVERY PHP error (can be adjusted)

bull Most expensive thing you can do is readwrite to IFS

bull usrlocalzendsvr6varlogphplog

bull ldquocliprdquo the logfile periodically

ndash Rename or delete

ndash Add this to weeklymonthly CL process

ndash PHP just creates a new one when it needs it

Rod Says 1Rod Says 2

11

Tip 10 ndash Read PHP logs

bull Lots of good stuff there

bull Notice errors can be expensive

bull Deprecated functions

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 5: Php tips for IBM i in 60 mins

5

Tip 4 ndash Develop with error reporting on

bull PHP is best suited for iterative development model

ndash Code Save Refresh Repeat

bull ALSO Find errors as you go at the script level

ndash error_reporting(-1) report all error levels

ndash ini_set(display_errors 1) show me the errors

bull Installation of Zend Server for Production turns this off

ndash COMMON for this to be off in single LPAR environments

ndash Get a developer LPAR (later)

bull Admin GUI

ndash PHPExtensions

6

Tip 5 ndash Get a Development LPAR

bull No more excuses

ndash IBM has made this MUCH easier (i on i)

ndash IBM has made this much less expensive

bull Couple thousand Disk RAM

bull Only one instance of Zend Server supported per LPAR

ndash Settings are global (phpini)

ndash Library list can be manipulated but isolation requires CHROOT etc

bull New PHP developers donrsquot get having dev amp prod on same LPAR

ndash ldquooff the streetrdquo struggle with one server let alone libl etchellip

ndash Can do dangerous things like issue ALTER TABLE to CUSTMAST

bull You are doing more with your IBM i now than ever before

ndash ldquoI never had a dev LPAR beforerdquo is not a valid excuse

ndash Give your devs the freedom to experiment

7

Tip 6 ndash Donrsquot write PHP like RPG

bull RPG applications often are built with main file then chains

ndash SETLL then READE ORDDETAIL

bull CHAIN PRODUCT

bull CHAIN INVENT

bull CHAIN ONPLAN

bull Consider a single SQL statement

ndash Join files are more efficient that chains in most cases

ndash SQL optimizers are genius

ndash Learn good indexing strategy

ndash Go to SQL sessions at conferences

ndash Ask Mike Cain hersquoll tell you

bull Great Redbooks

ndash Database modernization

ndash RPG and Application Modernization

8

Tip 7 ndash RTFM DB2

bull There is a wealth of information at phpnet

bull DB2 manual contains all functions for the DB2 extension

bull All of these can apply to PHP

ndash Column names counts

ndash Commitment control

ndash Prepared SQL (Good stuff)

bull httpphpnetmanualenbookibm-db2php

9

Tip 8 ndash Array creation shortcuts

bull PHP 54 introduced [ ]

ndash Old still supported $array1 = array(lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo)

ndash New method $array2 = [lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo]

ndash Implode explode

bull Arrays can also be constants in PHP7 Woohoo

10

Tip 9 ndash Performance of logs

bull PHP logfile captures EVERY PHP error (can be adjusted)

bull Most expensive thing you can do is readwrite to IFS

bull usrlocalzendsvr6varlogphplog

bull ldquocliprdquo the logfile periodically

ndash Rename or delete

ndash Add this to weeklymonthly CL process

ndash PHP just creates a new one when it needs it

Rod Says 1Rod Says 2

11

Tip 10 ndash Read PHP logs

bull Lots of good stuff there

bull Notice errors can be expensive

bull Deprecated functions

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 6: Php tips for IBM i in 60 mins

6

Tip 5 ndash Get a Development LPAR

bull No more excuses

ndash IBM has made this MUCH easier (i on i)

ndash IBM has made this much less expensive

bull Couple thousand Disk RAM

bull Only one instance of Zend Server supported per LPAR

ndash Settings are global (phpini)

ndash Library list can be manipulated but isolation requires CHROOT etc

bull New PHP developers donrsquot get having dev amp prod on same LPAR

ndash ldquooff the streetrdquo struggle with one server let alone libl etchellip

ndash Can do dangerous things like issue ALTER TABLE to CUSTMAST

bull You are doing more with your IBM i now than ever before

ndash ldquoI never had a dev LPAR beforerdquo is not a valid excuse

ndash Give your devs the freedom to experiment

7

Tip 6 ndash Donrsquot write PHP like RPG

bull RPG applications often are built with main file then chains

ndash SETLL then READE ORDDETAIL

bull CHAIN PRODUCT

bull CHAIN INVENT

bull CHAIN ONPLAN

bull Consider a single SQL statement

ndash Join files are more efficient that chains in most cases

ndash SQL optimizers are genius

ndash Learn good indexing strategy

ndash Go to SQL sessions at conferences

ndash Ask Mike Cain hersquoll tell you

bull Great Redbooks

ndash Database modernization

ndash RPG and Application Modernization

8

Tip 7 ndash RTFM DB2

bull There is a wealth of information at phpnet

bull DB2 manual contains all functions for the DB2 extension

bull All of these can apply to PHP

ndash Column names counts

ndash Commitment control

ndash Prepared SQL (Good stuff)

bull httpphpnetmanualenbookibm-db2php

9

Tip 8 ndash Array creation shortcuts

bull PHP 54 introduced [ ]

ndash Old still supported $array1 = array(lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo)

ndash New method $array2 = [lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo]

ndash Implode explode

bull Arrays can also be constants in PHP7 Woohoo

10

Tip 9 ndash Performance of logs

bull PHP logfile captures EVERY PHP error (can be adjusted)

bull Most expensive thing you can do is readwrite to IFS

bull usrlocalzendsvr6varlogphplog

bull ldquocliprdquo the logfile periodically

ndash Rename or delete

ndash Add this to weeklymonthly CL process

ndash PHP just creates a new one when it needs it

Rod Says 1Rod Says 2

11

Tip 10 ndash Read PHP logs

bull Lots of good stuff there

bull Notice errors can be expensive

bull Deprecated functions

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 7: Php tips for IBM i in 60 mins

7

Tip 6 ndash Donrsquot write PHP like RPG

bull RPG applications often are built with main file then chains

ndash SETLL then READE ORDDETAIL

bull CHAIN PRODUCT

bull CHAIN INVENT

bull CHAIN ONPLAN

bull Consider a single SQL statement

ndash Join files are more efficient that chains in most cases

ndash SQL optimizers are genius

ndash Learn good indexing strategy

ndash Go to SQL sessions at conferences

ndash Ask Mike Cain hersquoll tell you

bull Great Redbooks

ndash Database modernization

ndash RPG and Application Modernization

8

Tip 7 ndash RTFM DB2

bull There is a wealth of information at phpnet

bull DB2 manual contains all functions for the DB2 extension

bull All of these can apply to PHP

ndash Column names counts

ndash Commitment control

ndash Prepared SQL (Good stuff)

bull httpphpnetmanualenbookibm-db2php

9

Tip 8 ndash Array creation shortcuts

bull PHP 54 introduced [ ]

ndash Old still supported $array1 = array(lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo)

ndash New method $array2 = [lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo]

ndash Implode explode

bull Arrays can also be constants in PHP7 Woohoo

10

Tip 9 ndash Performance of logs

bull PHP logfile captures EVERY PHP error (can be adjusted)

bull Most expensive thing you can do is readwrite to IFS

bull usrlocalzendsvr6varlogphplog

bull ldquocliprdquo the logfile periodically

ndash Rename or delete

ndash Add this to weeklymonthly CL process

ndash PHP just creates a new one when it needs it

Rod Says 1Rod Says 2

11

Tip 10 ndash Read PHP logs

bull Lots of good stuff there

bull Notice errors can be expensive

bull Deprecated functions

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 8: Php tips for IBM i in 60 mins

8

Tip 7 ndash RTFM DB2

bull There is a wealth of information at phpnet

bull DB2 manual contains all functions for the DB2 extension

bull All of these can apply to PHP

ndash Column names counts

ndash Commitment control

ndash Prepared SQL (Good stuff)

bull httpphpnetmanualenbookibm-db2php

9

Tip 8 ndash Array creation shortcuts

bull PHP 54 introduced [ ]

ndash Old still supported $array1 = array(lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo)

ndash New method $array2 = [lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo]

ndash Implode explode

bull Arrays can also be constants in PHP7 Woohoo

10

Tip 9 ndash Performance of logs

bull PHP logfile captures EVERY PHP error (can be adjusted)

bull Most expensive thing you can do is readwrite to IFS

bull usrlocalzendsvr6varlogphplog

bull ldquocliprdquo the logfile periodically

ndash Rename or delete

ndash Add this to weeklymonthly CL process

ndash PHP just creates a new one when it needs it

Rod Says 1Rod Says 2

11

Tip 10 ndash Read PHP logs

bull Lots of good stuff there

bull Notice errors can be expensive

bull Deprecated functions

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 9: Php tips for IBM i in 60 mins

9

Tip 8 ndash Array creation shortcuts

bull PHP 54 introduced [ ]

ndash Old still supported $array1 = array(lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo)

ndash New method $array2 = [lsquoDogrsquo lsquoCatrsquo lsquoHamsterrsquo]

ndash Implode explode

bull Arrays can also be constants in PHP7 Woohoo

10

Tip 9 ndash Performance of logs

bull PHP logfile captures EVERY PHP error (can be adjusted)

bull Most expensive thing you can do is readwrite to IFS

bull usrlocalzendsvr6varlogphplog

bull ldquocliprdquo the logfile periodically

ndash Rename or delete

ndash Add this to weeklymonthly CL process

ndash PHP just creates a new one when it needs it

Rod Says 1Rod Says 2

11

Tip 10 ndash Read PHP logs

bull Lots of good stuff there

bull Notice errors can be expensive

bull Deprecated functions

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 10: Php tips for IBM i in 60 mins

10

Tip 9 ndash Performance of logs

bull PHP logfile captures EVERY PHP error (can be adjusted)

bull Most expensive thing you can do is readwrite to IFS

bull usrlocalzendsvr6varlogphplog

bull ldquocliprdquo the logfile periodically

ndash Rename or delete

ndash Add this to weeklymonthly CL process

ndash PHP just creates a new one when it needs it

Rod Says 1Rod Says 2

11

Tip 10 ndash Read PHP logs

bull Lots of good stuff there

bull Notice errors can be expensive

bull Deprecated functions

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 11: Php tips for IBM i in 60 mins

11

Tip 10 ndash Read PHP logs

bull Lots of good stuff there

bull Notice errors can be expensive

bull Deprecated functions

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 12: Php tips for IBM i in 60 mins

12

Tip 11 ndash Use opcode cache

bull PHP is interpreted

bull Each script is read from disk then parsed to opcode then run

bull Opcode cache can keep parsed copy in memory

bull All or nothing purge

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 13: Php tips for IBM i in 60 mins

13

Tip 12 ndash Data cache

bull Green screen lookup window vs drop down

bull Data Cache (Zend or APC) saves data in memory

bull Performance

bull White paper

bull Better performance for frequently access lists

bull Less stress on DB2

bull Aggregate values (BI)

bull Look at exampleshellip

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 14: Php tips for IBM i in 60 mins

14

Standard DB2 Call

bull 350+ Customer Orders

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 15: Php tips for IBM i in 60 mins

15

DB2 Call with Data Cache

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 16: Php tips for IBM i in 60 mins

16

Tip 13 ndash That ONE Connection

bull PHP can support multiple connections to DB2

ndash Also MySQL MSSQL Oracle etc

bull Only one connection required per DB more costs performance

ndash Multiple SQL statements and result sets can share a connection

ndash Connection consumes memory donrsquot waste

ndash Connection startup amp shutdown

bull Sometimes you need another connection

ndash If you need different LIBL

ndash Connecting to second partition

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 17: Php tips for IBM i in 60 mins

17

Tip 14 ndash Prepared SQL

bull Test in iNavhellip

bull DB2_Exec

bull DB2_Execute

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 18: Php tips for IBM i in 60 mins

18

Tip 15 ndash Stored Procedures

bull The fastest method for accessing data and business logic

bull Faster than the toolkit

bull Ubiquitous

bull If you have lsquoem use lsquoem

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 19: Php tips for IBM i in 60 mins

19

Before amp After PHP code originalhellip

19

Insert-gtHeader amp Footer

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 20: Php tips for IBM i in 60 mins

20

Before amp After PHP Code revised wSPhellip

20

Insert-gtHeader amp Footer

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 21: Php tips for IBM i in 60 mins

21

Tip 16 ndash Use a good Editor

bull Zend Studio is an IDE

ndash Syntax check Variable prompting (case sensitive)

ndash HTML JavaScript CSS support

ndash Free for first year

bull Notepad is painful

bull Other editors

ndash Notepad++

ndash Netbeans

ndash PHP Storm

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 22: Php tips for IBM i in 60 mins

22

Good Editor

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 23: Php tips for IBM i in 60 mins

23

Tip 17 ndash System Naming

bull Gives scripts a library list like logon screen

bull 3 ways to do library list (see other presentation DB2 Examples)

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 24: Php tips for IBM i in 60 mins

24

Tip 18 ndash Global Variables

bull Donrsquot us them

ndash Globals are the antithesis of functional development

ndash They are the GOTO of the variable world

ndash Remember RPG III Yep you get ithellip

bull But if you musthellip

ndash Develop a naming convention

ndash Prefix suffix something

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 25: Php tips for IBM i in 60 mins

25

Tip 19 ndash Static Typing

bull PHP 7 introduces many new features and scalar type hinting is onehellip

ndash httpphpnetmanualenmigration70php

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 26: Php tips for IBM i in 60 mins

26

Tip 20 ndash Static Typing (cont)

bull So is return typinghellip (Thanks Cal)

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 27: Php tips for IBM i in 60 mins

27

Tip 21 ndash Donrsquot Stop Learning

bull The PHP skills roadmap is long

ndash Thanks to functions productivity can happen at an early point

ndash You donrsquot necessarily need to embrace Frameworks right away

bull Object Oriented Programming offers

ndash Reuse

ndash Organization

bull Frameworks offer pre built code libraries

ndash Zend Framework is most popular in Enterprise

ndash Laravel is gaining ground

ndash Symfony also interesting

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 28: Php tips for IBM i in 60 mins

28

Tip 22 ndash Learn Design Patterns

bull Foundation of most frameworks

bull Developed initially for traffic management

bull Supports many methodologies

bull ZF1 ndash Singleton

bull ZF2 ndash Factory

bull Symfony

bull MVC is a design architecturehellipnot a pattern

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 29: Php tips for IBM i in 60 mins

29

Tip 23 ndash Google and PHPnet

bull Your two best friends in PHP development

bull When learning a new skill oftentimes donrsquot know question to ask

bull Google heuristics can estimate what you are looking for

ndash Often can lead you back to phpnet

ndash May lead to examples

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 30: Php tips for IBM i in 60 mins

30

Tip 24 ndash Just Do It

bull Donrsquot wait around for your boss to tell you

bull Find an excuse to play

bull Build a website (Go Daddy is $10 a month)

bull Volunteer

ndash Church

ndash VFW

ndash Local rock band

bull Internal department project

ndash IT help desk

ndash Intranet

ndash Media wiki for documentation

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 31: Php tips for IBM i in 60 mins

31

Tip 25 ndash OPC

bull Other Peoples Code

ndash Itrsquos how you learned RPGCOBOL

ndash Community loves to share but be careful not all good code

bull Google can help find resources

ndash Hotscriptscom Phpclassesorg Sourceforge

bull Sort by date descendinghellipfor most current stuff

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 32: Php tips for IBM i in 60 mins

32

OPChellip

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 33: Php tips for IBM i in 60 mins

33

Tip 26 ndash Test Driven Development

bull Continuous Delivery is the goal

bull Requires company to automate EVERY step in the software life cycle

bull Automate Testing start slow

ndash Create test scripts for functions

bull Phpunit

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 34: Php tips for IBM i in 60 mins

34

Tip 27 ndash Source Control

bull Existing commercial products handle PHP

ndash Rocket Arcad Remain Midrange Dynamics etc

bull Consider a code respository

ndash SVN GiT

bull You are doing more with this source code than ever before

ndash Maybe itrsquos time for a change

ndash Consider all the elements that make up a website

bull CSS HTML JavaScript

bull New resources require new ruleshellip

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 35: Php tips for IBM i in 60 mins

35

Tip 28 ndash Master SQL

bull IBM DB2 Extension uses same DB2 CLI as the native environment

bull Any changes to DB2 are immediately available to PHP

bull Every Technology Refresh contains changes to DB2 and often SQL

bull SQL is the primary language for data access in PHP

ndash Query optimizer

ndash iNav interface

ndash Index advisor

bull New httppublib-bboulderibmcomredpiecesabstractssg246503html

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 36: Php tips for IBM i in 60 mins

36

Tip 29 ndash Security

bull You are embarking on a new world (www)

bull Consider access to your data

bull Consider access to your IBM i

ndash Have you looked at your datasets

bull Take a networking class (the networkinternet is the computer)

Before

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 37: Php tips for IBM i in 60 mins

37

Tip 30 ndash Date Handling

bull Formatting dates in PHP is all about time stamps

bull DB2 installations usually store date as integers or date fields

bull To leverage PHP must master conversions

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 38: Php tips for IBM i in 60 mins

38

Tip 31 ndash Zend Server 9 Beta

bull Looking for a few good people

bull PHP7

bull Faster better

bull Still part of Basic edition license

bull LTS of PHP56 through 2020

ProductManagementzendcom

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 39: Php tips for IBM i in 60 mins

39

Tip 32 ndash Error Suppression

bull Embrace your mistakes

bull Use of the to suppress errors is still supported in PHP 7

ndash THIS IS BAD Equivalent of MONMSG CPF0000

bull Learn to handle errors

ndash Try amp Catch (example in samples)

ndash Exception processing

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 40: Php tips for IBM i in 60 mins

40

Tip 33 ndash Bit Twiddling 101

bull Consider this VERY carefully what is the most expensive resource

bull Single quotes vs double quotes

bull Echo vs Print

bull Sprint() instead of ldquordquo

bull Unset variables for memory management

bull Close database connection if you are done unless pconnect

bull $row[lsquoidrsquo] is faster than $row[id]

bull Static pages (html) are OK

bull Not everything has to be a Framework

ndash Fastest to slowest

bull Construct

bull Function

bull Static method

bull Object

bull Framework

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 41: Php tips for IBM i in 60 mins

41

Tip 34 ndash Never Trust External Data

bull Developer is agent of security in web app design

bull Filter inputs (Frameworks do this but so does PHP)

bull JavaScript may do this but that is not enoughhellip

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 42: Php tips for IBM i in 60 mins

42

Tip 35 ndash Hide Your Site Details

bull Netcraft knows all

bull Hide phpinfo

bull Never show a path Clean URLrsquos

bull Display errors in development ONLY

bull Expose_php in PHPini file to reduce visibility

Thank youmikepzendcom

Page 43: Php tips for IBM i in 60 mins

Thank youmikepzendcom