Pains and Gains of PHP
Upgrades
Lorna Mitchell, PHPNW December 2013
Slide 2
Slide 2 text
About Recent Versions of PHP
Version Released End of Life
5.2 November 2006 January 2011
5.3 June 2009 July 2014
5.4 March 2012 Release + 3 years
5.5 June 2013 Release + 3 years
Slide 3
Slide 3 text
Current PHP Installations
Slide 4
Slide 4 text
Pains of Upgrades
• cost (time and money)
• risk
Slide 5
Slide 5 text
Gains of Upgrades
• shiny new features
• better security
• better performance
Slide 6
Slide 6 text
Not All Upgrades Are Equal
• to 5.3: climbing a mountain
• to 5.4: flying leap
• to 5.5: nobody will notice
Slide 7
Slide 7 text
to PHP 5.3
Slide 8
Slide 8 text
PHP 5.3 is Full of Goodness
• namespaces
Slide 9
Slide 9 text
PHP Namespaces
Namespaces allow modularity and separation
• classes, constants and functions belong in
namespaces
• namespaces can be nested
• much easier pick-and-mix of
frameworks/libraries
• avoids naming collision
• key ingredient for PSR-0
PHP 5.3 is Full of Goodness
• namespaces
• anonymous functions
• better DateTime
• SPL data structures
• works on Windows
• E_DEPRECATED error reporting level
• late static binding
• __DIR__
Slide 16
Slide 16 text
Upgrading to 5.3: Gotchas
new reserved words: namespace, goto
log message changes
requires MySQL > 4.1
full info: http://lrnja.net/ZpvknE (php.net)
Slide 17
Slide 17 text
to PHP 5.4
Slide 18
Slide 18 text
PHP 5.4 is a Leap to the Future
• improved performance, reduced memory
footprint
Slide 19
Slide 19 text
PHP Performance
Slide 20
Slide 20 text
PHP 5.4 is a Leap to the Future
• improved performance, reduced memory
footprint
• built-in webserver
PHP 5.4 is a Leap to the Future
• improved performance, reduced memory
footprint
• built-in webserver
• traits
• short array notation, array dereferencing
• less nonsense
Slide 28
Slide 28 text
Upgrading to PHP 5.4: Gotchas
new reserved words: trait callable insteadof
no register_globals, short open tag etc
turn on E_DEPRECATED on your 5.3 platform
compile PHP 5.4 and use the webserver
Slide 29
Slide 29 text
Upgrading to PHP 5.4: Gotchas
new reserved words: trait callable insteadof
no register_globals, short open tag etc
turn on E_DEPRECATED on your 5.3 platform
compile PHP 5.4 and use the webserver
beware APC issues
Slide 30
Slide 30 text
to PHP 5.5
Slide 31
Slide 31 text
PHP 5.5: Better Again
• password hashing features
Slide 32
Slide 32 text
Easy Password Hashing
Slide 33
Slide 33 text
Easy Password Hashing
Slide 34
Slide 34 text
PHP 5.5: Better Again
• password hashing features
• generators
Slide 35
Slide 35 text
PHP Generators
Simpler than iterators - a function returning a
sequence of values.
Slide 36
Slide 36 text
PHP Generators
Simpler than iterators - a function returning a
sequence of values.
Slide 37
Slide 37 text
PHP 5.5: Better Again
• password hashing features
• generators
• try/catch/finally
Slide 38
Slide 38 text
Try/Catch/Finally
Finally is a clause that always gets run
Slide 39
Slide 39 text
No content
Slide 40
Slide 40 text
PHP 5.5: Better Again
• password hashing features
• generators
• try/catch/finally
• built-in opcode cache
• Turn on opcache.enable and
opcache.enable_cli
• use APCu
https://github.com/krakjoe/apcu
Slide 41
Slide 41 text
Upgrading to PHP 5.5
• turn on E_DEPRECATED on your 5.4 platform
• compile PHP 5.5 and use the webserver
Slide 42
Slide 42 text
In Summary
Slide 43
Slide 43 text
Upgrade, FFS
Slide 44
Slide 44 text
General Upgrade Plan
• check the changelog:
http://php.net/ChangeLog-5.php
• turn on E_DEPRECATED
• test with the webserver, run unit tests
with new binary
• upgrade test platform
• pecl extensions will need a reinstall
• go for it :)
Slide 45
Slide 45 text
Any Questions?
Contact me
• @lornajane
• http://lornajane.net
Slide 46
Slide 46 text
Appendices
Slide 47
Slide 47 text
PHP Version Adoption
• Version 5.3 52.2%
• Version 5.2 35.3%
• Version 5.4 9.8%
• Version 5.1 1.9%
• Version 5.5 0.7%
• Version 5.0 0.1%
• Version 5.6 < 0.1%
(From http://w3techs.com, 1 December 2013)
Slide 48
Slide 48 text
PHP Performance Comparisons
Average time to run bench.php on my laptop
• 5.2.17: 3.77 seconds
• 5.3.23: 2.63 seconds
• 5.4.15: 1.98 seconds
• 5.5RC1: 2.11 seconds