SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
The Why and How of moving to PHP 5.5/5.6
Who am I ?
Wim Godden (@wimgtr)
Founder of Cu.be Solutions (http://cu.be)
Open Source developer since 1997
Developer of OpenX, PHPCompatibility, PHPConsistent, ...
Speaker at Open Source conferences
Why vs How
Part 1 : why upgrade ?
Bad reasons :
It's cool to have the latest version
Annoy sysadmins
Oh cool, a new toy !
Part 2 : how to upgrade ?
The nightmare of compatibility
The joy of automation
No miracles here !
Show of hands
3 / 4
5.0
5.1
5.2
5.3
5.4
5.5
5.6
6.0
7.0
The numbers
W3Techs (http://w3techs.com/technologies/details/pl-php/all/all)
Now Nov 2013 Aug 2013 May 2013
PHP 4 : 1.8% 2.7% 2.9% 2.7%
PHP 5 : 98.2% 97.3% 97.1% 97.3%
5.0 : < 0.1% 0.1% 0.1% 0.1%
5.1 : 1.2% 2.0% 2.2% 2.6%
5.2 : 19.2% 37.6% 40.2% 43.5%
5.3 : 45.5% 52.0% 51.7% 49.7%
5.4 : 26.9% 7.9% 5.7% 4.1%
5.5 : 6.3% 0.5% 0.1 % < 0.1%
5.6 : 0.5% < 0.1%
5.7 : < 0.1%
5.27 : < 0.1%
5.3 quick recap
Namespaces ()
Late static binding
Closures
Better garbage collection
Goto
Mysqlnd
Performance gain
5.4 quick recap
Short array syntax
Function array dereferencing
Traits
Built-in webserver
SessionHandler
File upload extension
Binary notation
register_globals and magic_quotes_gpc removed :-)
Safe mode removed :-)
5.3 – people are not even using it !
19.2% still on PHP 5.2
No :
Symfony 2
Zend Framework 2
Other frameworks that need namespaces
Problematic for developers
PHP 5.5/5.6 – what's changed ?
New features
Performance and memory usage
Improved consistency
Some things removed
New things – Generators (5.5)
Simple way of implementing iterators
Simply put : foreach over a function
Say what ?
Generators - example
<?php
function returnAsciiTable($start, $end) {
for ($i = $start; $i <= $end; $i++) {
yield $i => chr($i);
}
}
foreach (returnAsciiTable(97, 122) as $key => $value) {
echo $key . " - " . $value . "n";
}
Output :
97 - a
98 - b
99 - c
100 - d
101 - e
102 - f
103 - g
104 - h
105 - i
106 - j
107 - k
108 - l
109 - m
110 - n
111 - o
112 - p
113 - q
114 - r
115 - s
116 - t
117 - u
118 - v
119 - w
120 - x
121 - y
122 - z
Finally : finally (5.5)
Exception handling
Until now : try {} catch() {}
Now :
<?php
try {
doSomething();
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "n";
} finally {
echo "We're always going here !";
}
Beware : finally + return
<?php
function footest()
{
try {
return 1;
} catch (Exception $e) {
return 2;
} finally {
return 10;
}
}
echo footest();
Will return 10 !
Password hashing (5.5)
To create :
$hash = password_hash($password, PASSWORD_DEFAULT);
To verify :
password_verify($password, $hash);
Currently only supports Blowfish
Also has password_needs_rehash() → check if hash was strong enough
Zend Optimizer+ (5.5)
Name in PHP 5.5 : OPcache
Opcode cache (like APC, Xcache, ...)
APC users : no userland (variable) caching in OPcache
→ Use APCu
Variadic functions
function sumNumbers($base, ...$params)
{
foreach ($params as $param) {
$base += $param;
}
return $base;
}
sumNumbers(5); // returns 5
sumNumbers(5, 2); // returns 7
sumNumbers(5, 2, 3); // returns 10
Argument unpacking
function add($a, $b, $c) {
return $a + $b + $c;
}
$params = array(2, 3);
echo add(5, ...$params); // returns 10
Other changes in 5.6
json_decode() strictness : true, false, null values
Constant expressions :
const ONE = 1;
const TWO = ONE * 2;
Exponent operator (**)
printf("2 ** 4 == %dn", 2 ** 4);
→ Output = 2 ** 4 == 16
use function and use const
Default charset is now UTF-8 → set in ini default_charset
__debuginfo() magic method for use with var_dump()
SSL/TLS security improvements (peer certificate verification,
TLS renegotiation attacks, …)
phpdbg : interactive debugger
Removed features in PHP 5.5
php_logo_guid()
php_egg_logo_guid()
php_real_logo_guid()
zend_logo_guid()
Windows XP and 2003 support
Removed features in PHP 5.6
$HTTP_RAW_POST_DATA and ini setting
always_populate_raw_post_data
iconv and mbstring encoding settings → default_charset in ini
Performance and memory usage from 5.3 to 5.6
Performance : 10 – 30%
How ?
Core optimizations
New internal caches (functions, constants, …)
Better (un)serialization
Inlining often-used code paths
…
Reduced memory usage : up to 50% !
Big impact on large frameworks
Even bigger impact on codebases such as Drupal
So...
Should you upgrade today ?
Upgrade : yes / no
Yes No
Using removed extensions x
Using removed functions x
Need extra performance / reduced memory x
Really need new feature x
Want to use recent framework x
No unit tests x
No package available (.rpm, .deb, ...) x
Postponing upgrades
End-Of-Life
In the past : we'll see
Now : minor release + 2 = out → EOL
5.5 = OUT → 5.3 = EOL
5.6 = OUT → 5.4 = EOL
Critical security patches : 1 year
No bugfixes
Framework support
Developer motivation
So you want to upgrade...
Option 1 : run your unit tests
Option 2 : visit each page (good luck !) + check error_log
Or : record visits, then replay log on test environment
Option 3 : automated static analysis
Unit tests on different PHP versions
Vagrant boxes
Integrate into your CI
Use Travis CI (http://travis-ci.org)
Why make it so hard ? A best-case scenario...
Development environment : 5.6
Production environment : 5.6
All is well, right ?
End 2015 : PHP 7 arrives
How can you test compatibility ?
→ Set up your test environment today
→ Even for new projects
Back in 2010...
PHP Architect @ Belgian Railways
8 years of legacy code
40+ different developers
40+ projects
Challenge :
migrate all projects from
PHP 5.1.x (on Solaris)
to
PHP 5.3.x (on Linux)
The idea
Automate it
How ? → Use the CI environment
Which tool ? → PHP_CodeSniffer
PHP_CodeSniffer
PEAR package (pear install PHP_CodeSniffer)
Detect coding standard violations
Supports multiple standards
Static analysis tool
→ Runs without executing code
→ Splits code in tokens
Ex. : T_OPEN_CURLY_BRACKET
T_FALSE
T_SEMICOLON
PHP_CodeSniffer
Let's see what it looks like
PHPCompatibility
New PHP_CodeSniffer standard
Only purpose : find compatibility issues
Detects :
Deprecated functions
Deprecated extensions
Deprecated php.ini settings and ini_set() calls
Prohibited function names, class names, …
…
Works for PHP 5.0 and above
PHPCompatibility – making it work
Via Composer : wimg/php-compatibility
From Github :
Download :
http://github.com/wimg/PHPCompatibility
Install in <pear_dir>/PHP/CodeSniffer/Standards
Run :
phpcs --standard=PHPCompatibility <path>
PHPCompatibility
Let's see what it looks like
Important notes
Large directories → can be slow !
Use --extensions=php,phtml
No point scanning .js files
Static analysis
Doesn't run code
Can not detect every single incompatibility
Provides filename and line number
The result
Zend Framework 1.7 app
PHP 5.2 : working fine
PHP 5.3 : fail !
function goto()
Some common apps – phpBB (latest)
FILE: /usr/src/phpBB3/adm/index.php
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 2 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
48 | WARNING | INI directive 'safe_mode' is deprecated in PHP 5.3 and forbidden in PHP 5.4.
48 | WARNING | INI directive 'safe_mode' is deprecated in PHP 5.3 and forbidden in PHP 5.4.
--------------------------------------------------------------------------------
Common apps - MediaWiki
FILE: /usr/src/mediawiki-1.19.8/includes/GlobalFunctions.php
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
2705 | WARNING | The use of function dl is discouraged in PHP version 5.3 and
| | discouraged in PHP version 5.4 and discouraged in PHP version
| | 5.5
--------------------------------------------------------------------------------
Common apps – Wordpress (latest)
FILE: /usr/src/wordpress/wp-admin/includes/class-pclzip.php
--------------------------------------------------------------------------------
FOUND 2 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
5340 | ERROR | The use of function set_magic_quotes_runtime is discouraged in
| | PHP version 5.3 and forbidden in PHP version 5.4 and forbidden
| | in PHP version 5.5
5371 | ERROR | The use of function set_magic_quotes_runtime is discouraged in
| | PHP version 5.3 and forbidden in PHP version 5.4 and forbidden
| | in PHP version 5.5
--------------------------------------------------------------------------------
FILE: /usr/src/wordpress/wp-includes/SimplePie/Item.php
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
125 | WARNING | INI directive 'zend.ze1_compatibility_mode' is deprecated in
| | PHP 5.3 and forbidden in PHP 5.4.
--------------------------------------------------------------------------------
FILE: /usr/src/wordpress/wp-includes/wp-db.php
--------------------------------------------------------------------------------
FOUND 16 ERROR(S) AFFECTING 16 LINE(S)
--------------------------------------------------------------------------------
641 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 - use mysqli
| | instead.
646 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 - use mysqli
| | instead.
Conclusion
No 100% detection
But : 95% automation = lots of time saved !
First : PHPCompatibility on local machine
Then : use your CI/test environment and run unit tests
Start upgrading !
Questions ?
Questions ?
We're hiring !
Looking for a challenge ?
Want to do more than just code all day ?
→ Come visit our booth !
We've got chocolate ;-)
Thanks !
Please rate my talk at
http://joind.in/13113

Weitere ähnliche Inhalte

Was ist angesagt?

Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)julien pauli
 
Mysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionjulien pauli
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPANcharsbar
 
An introduction to PHP 5.4
An introduction to PHP 5.4An introduction to PHP 5.4
An introduction to PHP 5.4Giovanni Derks
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Shinya Ohyanagi
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesEric Poe
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and coPierre Joye
 
PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015Colin O'Dell
 
2016年のPerl (Long version)
2016年のPerl (Long version)2016年のPerl (Long version)
2016年のPerl (Long version)charsbar
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from insidejulien pauli
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLitecharsbar
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13julien pauli
 
The Php Life Cycle
The Php Life CycleThe Php Life Cycle
The Php Life CycleXinchen Hui
 
eZ Publish Caching Mechanisms
eZ Publish Caching MechanismseZ Publish Caching Mechanisms
eZ Publish Caching MechanismsKaliop-slide
 
Profiling php5 to php7
Profiling php5 to php7Profiling php5 to php7
Profiling php5 to php7julien pauli
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS charsbar
 

Was ist angesagt? (20)

Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
 
Mysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extension
 
PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
 
An introduction to PHP 5.4
An introduction to PHP 5.4An introduction to PHP 5.4
An introduction to PHP 5.4
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
 
PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015
 
2016年のPerl (Long version)
2016年のPerl (Long version)2016年のPerl (Long version)
2016年のPerl (Long version)
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from inside
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLite
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
The Php Life Cycle
The Php Life CycleThe Php Life Cycle
The Php Life Cycle
 
eZ Publish Caching Mechanisms
eZ Publish Caching MechanismseZ Publish Caching Mechanisms
eZ Publish Caching Mechanisms
 
Profiling php5 to php7
Profiling php5 to php7Profiling php5 to php7
Profiling php5 to php7
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS
 

Andere mochten auch

Php basics
Php basicsPhp basics
Php basicshamfu
 
PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?Nick Belhomme
 
Php tutorial
Php tutorialPhp tutorial
Php tutorialNiit
 
Performance Comparison of PHP 5.6 vs. 7.0 vs HHVM
Performance Comparison of PHP 5.6 vs. 7.0 vs HHVMPerformance Comparison of PHP 5.6 vs. 7.0 vs HHVM
Performance Comparison of PHP 5.6 vs. 7.0 vs HHVMJani Tarvainen
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developersWim Godden
 
Modified maximum tangential stress criterion for fracture behavior of zirconi...
Modified maximum tangential stress criterion for fracture behavior of zirconi...Modified maximum tangential stress criterion for fracture behavior of zirconi...
Modified maximum tangential stress criterion for fracture behavior of zirconi...dentalid
 
Program rada i financijski plan 2015.
Program rada i financijski plan 2015.Program rada i financijski plan 2015.
Program rada i financijski plan 2015.stipepetrina
 
Understanding Product/Market Fit
Understanding Product/Market FitUnderstanding Product/Market Fit
Understanding Product/Market FitGabor Papp
 
Márkaépítés a fogyasztói kontroll korában 2.0
Márkaépítés a fogyasztói kontroll korában 2.0Márkaépítés a fogyasztói kontroll korában 2.0
Márkaépítés a fogyasztói kontroll korában 2.0Isobar Budapest
 
Il Web E Le Reti Di Vendita
Il Web E Le Reti Di Vendita Il Web E Le Reti Di Vendita
Il Web E Le Reti Di Vendita Gagliano Giuseppe
 
Engaging Students Virtually Throughout the Enrollment Cycle
Engaging Students Virtually Throughout the Enrollment CycleEngaging Students Virtually Throughout the Enrollment Cycle
Engaging Students Virtually Throughout the Enrollment CycleMarty Bennett
 
LR KONKURENCIJOS TARYBOS (KT) 2015 m. VEIKLOS ATASKAITA
LR KONKURENCIJOS TARYBOS (KT) 2015 m. VEIKLOS ATASKAITALR KONKURENCIJOS TARYBOS (KT) 2015 m. VEIKLOS ATASKAITA
LR KONKURENCIJOS TARYBOS (KT) 2015 m. VEIKLOS ATASKAITAArunas Vizickas ✔
 
DALLA DELUSIONE ALLA SPERANZA
DALLA DELUSIONE ALLA SPERANZADALLA DELUSIONE ALLA SPERANZA
DALLA DELUSIONE ALLA SPERANZASimone Tranquilli
 
Letter s presentatie
Letter s presentatieLetter s presentatie
Letter s presentatiecmagarry
 
Go言語
Go言語Go言語
Go言語na_o_ys
 

Andere mochten auch (20)

Php basics
Php basicsPhp basics
Php basics
 
PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?
 
Php
PhpPhp
Php
 
PHP slides
PHP slidesPHP slides
PHP slides
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
RESUME (2)
RESUME (2)RESUME (2)
RESUME (2)
 
Performance Comparison of PHP 5.6 vs. 7.0 vs HHVM
Performance Comparison of PHP 5.6 vs. 7.0 vs HHVMPerformance Comparison of PHP 5.6 vs. 7.0 vs HHVM
Performance Comparison of PHP 5.6 vs. 7.0 vs HHVM
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developers
 
Modified maximum tangential stress criterion for fracture behavior of zirconi...
Modified maximum tangential stress criterion for fracture behavior of zirconi...Modified maximum tangential stress criterion for fracture behavior of zirconi...
Modified maximum tangential stress criterion for fracture behavior of zirconi...
 
Program rada i financijski plan 2015.
Program rada i financijski plan 2015.Program rada i financijski plan 2015.
Program rada i financijski plan 2015.
 
Understanding Product/Market Fit
Understanding Product/Market FitUnderstanding Product/Market Fit
Understanding Product/Market Fit
 
Márkaépítés a fogyasztói kontroll korában 2.0
Márkaépítés a fogyasztói kontroll korában 2.0Márkaépítés a fogyasztói kontroll korában 2.0
Márkaépítés a fogyasztói kontroll korában 2.0
 
Il Web E Le Reti Di Vendita
Il Web E Le Reti Di Vendita Il Web E Le Reti Di Vendita
Il Web E Le Reti Di Vendita
 
Engaging Students Virtually Throughout the Enrollment Cycle
Engaging Students Virtually Throughout the Enrollment CycleEngaging Students Virtually Throughout the Enrollment Cycle
Engaging Students Virtually Throughout the Enrollment Cycle
 
LR KONKURENCIJOS TARYBOS (KT) 2015 m. VEIKLOS ATASKAITA
LR KONKURENCIJOS TARYBOS (KT) 2015 m. VEIKLOS ATASKAITALR KONKURENCIJOS TARYBOS (KT) 2015 m. VEIKLOS ATASKAITA
LR KONKURENCIJOS TARYBOS (KT) 2015 m. VEIKLOS ATASKAITA
 
DALLA DELUSIONE ALLA SPERANZA
DALLA DELUSIONE ALLA SPERANZADALLA DELUSIONE ALLA SPERANZA
DALLA DELUSIONE ALLA SPERANZA
 
Letter s presentatie
Letter s presentatieLetter s presentatie
Letter s presentatie
 
Happy New Year
Happy New Year Happy New Year
Happy New Year
 
Go言語
Go言語Go言語
Go言語
 

Ähnlich wie The why and how of moving to PHP 5.5/5.6

The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7Wim Godden
 
The why and how of moving to php 8
The why and how of moving to php 8The why and how of moving to php 8
The why and how of moving to php 8Wim Godden
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.xWim Godden
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.xWim Godden
 
第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会Ippei Ogiwara
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshopjulien pauli
 
DevOps in PHP environment
DevOps in PHP environmentDevOps in PHP environment
DevOps in PHP environmentEvaldo Felipe
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009PHPBelgium
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202Mahmoud Samir Fayed
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Joseph Scott
 
Tips
TipsTips
Tipsmclee
 
php & performance
 php & performance php & performance
php & performancesimon8410
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Fabrice Bernhard
 
What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7Codemotion
 
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008phpbarcelona
 
Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8Ran Mizrahi
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshopjulien pauli
 

Ähnlich wie The why and how of moving to PHP 5.5/5.6 (20)

The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7
 
The why and how of moving to php 8
The why and how of moving to php 8The why and how of moving to php 8
The why and how of moving to php 8
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.x
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.x
 
第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshop
 
DevOps in PHP environment
DevOps in PHP environmentDevOps in PHP environment
DevOps in PHP environment
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
 
Tips
TipsTips
Tips
 
php & performance
 php & performance php & performance
php & performance
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7
 
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
 
Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshop
 
Sa
SaSa
Sa
 

Mehr von Wim Godden

Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to lifeWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websocketsWim Godden
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to lifeWim Godden
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developersWim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websocketsWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous phpWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
Practical git for developers
Practical git for developersPractical git for developers
Practical git for developersWim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous phpWim Godden
 

Mehr von Wim Godden (20)

Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to life
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websockets
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to life
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developers
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websockets
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous php
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Practical git for developers
Practical git for developersPractical git for developers
Practical git for developers
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous php
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Kürzlich hochgeladen (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

The why and how of moving to PHP 5.5/5.6

  • 1. The Why and How of moving to PHP 5.5/5.6
  • 2. Who am I ? Wim Godden (@wimgtr) Founder of Cu.be Solutions (http://cu.be) Open Source developer since 1997 Developer of OpenX, PHPCompatibility, PHPConsistent, ... Speaker at Open Source conferences
  • 3. Why vs How Part 1 : why upgrade ? Bad reasons : It's cool to have the latest version Annoy sysadmins Oh cool, a new toy ! Part 2 : how to upgrade ? The nightmare of compatibility The joy of automation No miracles here !
  • 4. Show of hands 3 / 4 5.0 5.1 5.2 5.3 5.4 5.5 5.6 6.0 7.0
  • 5. The numbers W3Techs (http://w3techs.com/technologies/details/pl-php/all/all) Now Nov 2013 Aug 2013 May 2013 PHP 4 : 1.8% 2.7% 2.9% 2.7% PHP 5 : 98.2% 97.3% 97.1% 97.3% 5.0 : < 0.1% 0.1% 0.1% 0.1% 5.1 : 1.2% 2.0% 2.2% 2.6% 5.2 : 19.2% 37.6% 40.2% 43.5% 5.3 : 45.5% 52.0% 51.7% 49.7% 5.4 : 26.9% 7.9% 5.7% 4.1% 5.5 : 6.3% 0.5% 0.1 % < 0.1% 5.6 : 0.5% < 0.1% 5.7 : < 0.1% 5.27 : < 0.1%
  • 6. 5.3 quick recap Namespaces () Late static binding Closures Better garbage collection Goto Mysqlnd Performance gain
  • 7. 5.4 quick recap Short array syntax Function array dereferencing Traits Built-in webserver SessionHandler File upload extension Binary notation register_globals and magic_quotes_gpc removed :-) Safe mode removed :-)
  • 8. 5.3 – people are not even using it ! 19.2% still on PHP 5.2 No : Symfony 2 Zend Framework 2 Other frameworks that need namespaces Problematic for developers
  • 9. PHP 5.5/5.6 – what's changed ? New features Performance and memory usage Improved consistency Some things removed
  • 10. New things – Generators (5.5) Simple way of implementing iterators Simply put : foreach over a function Say what ?
  • 11. Generators - example <?php function returnAsciiTable($start, $end) { for ($i = $start; $i <= $end; $i++) { yield $i => chr($i); } } foreach (returnAsciiTable(97, 122) as $key => $value) { echo $key . " - " . $value . "n"; } Output : 97 - a 98 - b 99 - c 100 - d 101 - e 102 - f 103 - g 104 - h 105 - i 106 - j 107 - k 108 - l 109 - m 110 - n 111 - o 112 - p 113 - q 114 - r 115 - s 116 - t 117 - u 118 - v 119 - w 120 - x 121 - y 122 - z
  • 12. Finally : finally (5.5) Exception handling Until now : try {} catch() {} Now : <?php try { doSomething(); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "n"; } finally { echo "We're always going here !"; }
  • 13. Beware : finally + return <?php function footest() { try { return 1; } catch (Exception $e) { return 2; } finally { return 10; } } echo footest(); Will return 10 !
  • 14. Password hashing (5.5) To create : $hash = password_hash($password, PASSWORD_DEFAULT); To verify : password_verify($password, $hash); Currently only supports Blowfish Also has password_needs_rehash() → check if hash was strong enough
  • 15. Zend Optimizer+ (5.5) Name in PHP 5.5 : OPcache Opcode cache (like APC, Xcache, ...) APC users : no userland (variable) caching in OPcache → Use APCu
  • 16. Variadic functions function sumNumbers($base, ...$params) { foreach ($params as $param) { $base += $param; } return $base; } sumNumbers(5); // returns 5 sumNumbers(5, 2); // returns 7 sumNumbers(5, 2, 3); // returns 10
  • 17. Argument unpacking function add($a, $b, $c) { return $a + $b + $c; } $params = array(2, 3); echo add(5, ...$params); // returns 10
  • 18. Other changes in 5.6 json_decode() strictness : true, false, null values Constant expressions : const ONE = 1; const TWO = ONE * 2; Exponent operator (**) printf("2 ** 4 == %dn", 2 ** 4); → Output = 2 ** 4 == 16 use function and use const Default charset is now UTF-8 → set in ini default_charset __debuginfo() magic method for use with var_dump() SSL/TLS security improvements (peer certificate verification, TLS renegotiation attacks, …) phpdbg : interactive debugger
  • 19. Removed features in PHP 5.5 php_logo_guid() php_egg_logo_guid() php_real_logo_guid() zend_logo_guid() Windows XP and 2003 support
  • 20. Removed features in PHP 5.6 $HTTP_RAW_POST_DATA and ini setting always_populate_raw_post_data iconv and mbstring encoding settings → default_charset in ini
  • 21. Performance and memory usage from 5.3 to 5.6 Performance : 10 – 30% How ? Core optimizations New internal caches (functions, constants, …) Better (un)serialization Inlining often-used code paths … Reduced memory usage : up to 50% ! Big impact on large frameworks Even bigger impact on codebases such as Drupal
  • 23. Upgrade : yes / no Yes No Using removed extensions x Using removed functions x Need extra performance / reduced memory x Really need new feature x Want to use recent framework x No unit tests x No package available (.rpm, .deb, ...) x
  • 24. Postponing upgrades End-Of-Life In the past : we'll see Now : minor release + 2 = out → EOL 5.5 = OUT → 5.3 = EOL 5.6 = OUT → 5.4 = EOL Critical security patches : 1 year No bugfixes Framework support Developer motivation
  • 25. So you want to upgrade... Option 1 : run your unit tests Option 2 : visit each page (good luck !) + check error_log Or : record visits, then replay log on test environment Option 3 : automated static analysis
  • 26. Unit tests on different PHP versions Vagrant boxes Integrate into your CI Use Travis CI (http://travis-ci.org)
  • 27. Why make it so hard ? A best-case scenario... Development environment : 5.6 Production environment : 5.6 All is well, right ? End 2015 : PHP 7 arrives How can you test compatibility ? → Set up your test environment today → Even for new projects
  • 28. Back in 2010... PHP Architect @ Belgian Railways 8 years of legacy code 40+ different developers 40+ projects Challenge : migrate all projects from PHP 5.1.x (on Solaris) to PHP 5.3.x (on Linux)
  • 29. The idea Automate it How ? → Use the CI environment Which tool ? → PHP_CodeSniffer
  • 30. PHP_CodeSniffer PEAR package (pear install PHP_CodeSniffer) Detect coding standard violations Supports multiple standards Static analysis tool → Runs without executing code → Splits code in tokens Ex. : T_OPEN_CURLY_BRACKET T_FALSE T_SEMICOLON
  • 32. PHPCompatibility New PHP_CodeSniffer standard Only purpose : find compatibility issues Detects : Deprecated functions Deprecated extensions Deprecated php.ini settings and ini_set() calls Prohibited function names, class names, … … Works for PHP 5.0 and above
  • 33. PHPCompatibility – making it work Via Composer : wimg/php-compatibility From Github : Download : http://github.com/wimg/PHPCompatibility Install in <pear_dir>/PHP/CodeSniffer/Standards Run : phpcs --standard=PHPCompatibility <path>
  • 35. Important notes Large directories → can be slow ! Use --extensions=php,phtml No point scanning .js files Static analysis Doesn't run code Can not detect every single incompatibility Provides filename and line number
  • 36. The result Zend Framework 1.7 app PHP 5.2 : working fine PHP 5.3 : fail ! function goto()
  • 37. Some common apps – phpBB (latest) FILE: /usr/src/phpBB3/adm/index.php -------------------------------------------------------------------------------- FOUND 0 ERROR(S) AND 2 WARNING(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 48 | WARNING | INI directive 'safe_mode' is deprecated in PHP 5.3 and forbidden in PHP 5.4. 48 | WARNING | INI directive 'safe_mode' is deprecated in PHP 5.3 and forbidden in PHP 5.4. --------------------------------------------------------------------------------
  • 38. Common apps - MediaWiki FILE: /usr/src/mediawiki-1.19.8/includes/GlobalFunctions.php -------------------------------------------------------------------------------- FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 2705 | WARNING | The use of function dl is discouraged in PHP version 5.3 and | | discouraged in PHP version 5.4 and discouraged in PHP version | | 5.5 --------------------------------------------------------------------------------
  • 39. Common apps – Wordpress (latest) FILE: /usr/src/wordpress/wp-admin/includes/class-pclzip.php -------------------------------------------------------------------------------- FOUND 2 ERROR(S) AFFECTING 2 LINE(S) -------------------------------------------------------------------------------- 5340 | ERROR | The use of function set_magic_quotes_runtime is discouraged in | | PHP version 5.3 and forbidden in PHP version 5.4 and forbidden | | in PHP version 5.5 5371 | ERROR | The use of function set_magic_quotes_runtime is discouraged in | | PHP version 5.3 and forbidden in PHP version 5.4 and forbidden | | in PHP version 5.5 -------------------------------------------------------------------------------- FILE: /usr/src/wordpress/wp-includes/SimplePie/Item.php -------------------------------------------------------------------------------- FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 125 | WARNING | INI directive 'zend.ze1_compatibility_mode' is deprecated in | | PHP 5.3 and forbidden in PHP 5.4. -------------------------------------------------------------------------------- FILE: /usr/src/wordpress/wp-includes/wp-db.php -------------------------------------------------------------------------------- FOUND 16 ERROR(S) AFFECTING 16 LINE(S) -------------------------------------------------------------------------------- 641 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 - use mysqli | | instead. 646 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 - use mysqli | | instead.
  • 40. Conclusion No 100% detection But : 95% automation = lots of time saved ! First : PHPCompatibility on local machine Then : use your CI/test environment and run unit tests Start upgrading !
  • 43. We're hiring ! Looking for a challenge ? Want to do more than just code all day ? → Come visit our booth ! We've got chocolate ;-)
  • 44. Thanks ! Please rate my talk at http://joind.in/13113

Hinweis der Redaktion

  1. part 2 look at difficulties you might encounter in upgrading. I&amp;apos;ll provide solutions not a magician can&amp;apos;t solve everything ;-)
  2. 5.3.3 = Debian Squeezy = 12% Wait a second... that means people aren&amp;apos;t even on 5.3 ? And there was 3 year gap between the release of 5.2 and 5.3, so 5.3 brought a lot of cool things.
  3. - Compression disabled by default (CRIME attack) - Ciphers have been updated - Possible to select specific SSL/TLS version