bringing modern php development to ibm i (zendcon 2016)

92
@asgrim Bringing Modern PHP Development to IBM i James Titcumb ZendCon 2016

Upload: james-titcumb

Post on 26-Jan-2017

108 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Bringing Modern PHP Development to IBM i

James TitcumbZendCon 2016

Page 2: Bringing modern PHP development to IBM i (ZendCon 2016)

Who is this guy?

James Titcumbwww.jamestitcumb.com

www.roave.com

www.phphants.co.uk

www.phpsouthcoast.co.uk

@asgrim

Page 3: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

ZendCon 2015.

Page 4: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Hey James!

Page 5: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Sure...

Page 6: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

...

Page 7: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

IBM i

Page 8: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Let’s get comfortable.

Page 9: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

RPG

Page 10: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

RPG !== Rocket Propelled Grenade

Page 11: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

The preconception...

Page 12: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Page 13: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Image: http://www.gregdonner.org/workbench/wb_10.html

Page 14: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

But.

Page 15: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

tn5250

Page 16: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

CALL QP2TERM

Page 17: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Page 18: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

SSH

Page 19: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

BASH

Page 20: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

~/.profile

SHELL=/bin/bash exec /bin/bash

# or /QOpenSys/QIBM/ProdData/OPS/tools/bin/bash

Page 21: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

~/.bashrc

# set a fancy prompt (non-color, unless we know we "want" color)

case "$TERM" in

xterm-color) color_prompt=yes;;

esac

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u' \

'@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

export PATH=$PATH:/usr/local/zendsvr6/bin

Page 22: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

vi

$ vi <filename>

xterm-256color: Unknown terminal type

[Hit return to continue]

Page 23: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

vi

$ export TERM=xterm

$ vi <filename>

Page 24: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Permissions

Page 25: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

git

Page 26: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

GitHub

Page 27: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

http://yips.idevcloud.com/wiki/index.php/PASE/Git

Page 28: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

PHP !!!

Page 29: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Page 30: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Composer

Page 31: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Composer installation

$ php -r "copy('https://getcomposer.org/installer',

'composer-setup.php');"

$ php -r "if (hash_file('SHA384', 'composer-setup.php') ===

'...') { echo 'Installer verified'; } else { echo

'Installer corrupt'; unlink('composer-setup.php'); } echo

PHP_EOL;"

$ php composer-setup.php

$ php -r "unlink('composer-setup.php');"

Page 32: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Composer installation

$ mv composer.phar /usr/local/zendsvr6/bin/composer

$ composer ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___// /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/

Composer version 1.2.1 2016-09-12 11:27:19

$

Page 33: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

GitHub Flow

Page 34: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

master

Page 35: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

my-feature

master

Page 36: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

my-feature

master

Page 37: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

my-feature

master

Page 38: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Rebasing

Page 39: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

my-featureA

master

B

Page 40: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

my-featureA

master

B

A

Page 41: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

my-featureA

master

B

A

B

Page 42: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

my-feature

master

A

B

Page 43: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

master

A

B

!my-feature

A

B

Page 44: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

my-feature

master

A

B

A

B

!

Page 45: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Development Practices

Page 46: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Code Defensively

Page 47: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

SOLID

Page 48: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Composition over Inheritance

Page 49: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Composition over Inheritance

final class Thing implements ThingInterface{ public function foo() { // (does something) }}final class CachingThing implements ThingInterface{ public function __construct(ThingInterface $real, CacheInterface $cache) { $this->real = $real; $this->cache = $cache; } public function foo() { if (!$this->cache->has('foo')) { $this->cache->put('foo', $this->real->foo()); } return $this->cache->get('foo'); }}

Page 50: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Testing

Page 51: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Naming things

Page 52: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Separation of concerns

Page 53: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Use PHP 7 (when it’s out)

Page 54: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Automate all the things!

Page 55: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

phpunit

Page 56: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

xdebug

Page 57: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

phpcs

Page 58: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

phpmd

Page 59: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Your favourite IDE

Page 60: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

phpcpd

Page 61: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

php -l <filename>

Page 62: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Behat

Page 63: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Continuous Integration

Page 64: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Jenkins

Page 65: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

jenkins-php.org

Page 66: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Bamboo

Page 67: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

TeamCity + Upsource

Page 68: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Run it on IBM i

Page 69: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Integrate with GitHub

Page 70: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Page 71: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Code Review

Page 72: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Code Reviews

Page 73: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Good design

Page 74: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Semantics & Readability

Page 75: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Does it actually work?

Page 76: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Security

Page 77: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Performance

Page 78: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Page 79: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Behat on IBM i

Page 80: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Local Development

Page 81: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Vagrant

Page 82: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

What about Docker?

Page 83: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Database

Page 84: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

DB2 for LUW vs DB2 for i

Page 85: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

https://github.com/alanseiden/doctrine-dbal-ibmi

Page 86: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Doctrine ORM

Page 87: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Migrations

Page 88: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Deployment

Page 89: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Deployment Automation

Page 90: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Rollback

Page 91: Bringing modern PHP development to IBM i (ZendCon 2016)

@asgrim

Summary

● Set up a familiar working environment● Git + GitHub● Use Zend Server for PHP● Composer for dependencies● GitHub Flow + rebasing branching strategy● Use good development practices● Automate testing, coverage, coding standards, etc.● Set up Continuous Integration builds● Code Review every change (PR)● Local development makes things easier● Use a good DBAL● One-click-deployments are mandatory

Page 92: Bringing modern PHP development to IBM i (ZendCon 2016)

Any questions?

http://joind.in/

James Titcumb @asgrim