7. PHP : When ?
● We've always released version whenever we
wanted to
– 5.0 (2004)
– 5.1 (2005)
– 5.2 (2006)
– 5.3 (2009)
– 5.4 (2011)
– 5.5 (2013)
● Starting with 5.4, we have a process
8. PHP release process
● https://wiki.php.net/rfc/releaseprocess
● Yearly new major/minor (5.4->5.5 or 6.0)
– New features
– Big changes. Majors may break BC
– 3 years of life (2 + 1)
● Monthly new revisions (5.4.3->5.4.4)
– Bug fixes, no new features, BC kept
● EOLed security releases
– After EOL, 1 year of security fixes
9. PHP contributors
● Not so many contributors worldwide
– About 10~20 regular ppl
– Hundreds total
● Lots of ways to contribute
– Code (sure)
– Report bugs, write more tests
– Documentation, translations
– Infrastructure : php.net
● But how many PHP users worldwide ?
11. PHP 5.5 menu
● Password hashing API
● Generators
● "Finally" keyword
● OPCode cache integration
● Syntax and engine improvements
● Class name to scalar
● Breaks & deprecations
12. New Password hashing API
● PHP users don't really understand/care
about the concept behing hashing, salting
and crypting
● PHP doesn't give any hints about that
● User are left on their own
– Until 5.5 version
– Welcome a new password hashing API !
13. New Password hashing API
● http://www.php.net/password
● See how easy that looks now :
– To generate a hash
$password = 'secret';
$hash = password_hash($password, PASSWORD_DEFAULT);
var_dump($hash);
// "$2y$10$Pa2cIqH5X3m6iqIYVDBdvOUcggnXnZzBy0dlie
4VRHLr3ncLcyB7a"
14. New Password hashing API
● http://www.php.net/password
● See how easy that looks now :
– To verify a hash
$provided_password = 'secret';
$hash = "$2y$10$Pa2cIqH5X3m6iqIYVDBdvOUcggnXnZzBy0
dlie4VRHLr3ncLcyB7a";
if (password_verify($provided_password, $hash)) {
echo "you are welcome" ;
}
15. New Password hashing API
● More options :
– choose your hashing algorithm
– choose a salt from yours
– choose a CPU cost
$password = "mysecret" ;
$hash =password_hash($password, PASSWORD_BCRYPT,
array("cost" => 5, "salt" => "my_secret_salt") ) ;
16. New Password hashing API
● Just one Database field is needed
● The hash encapsulates all the infos
– algorithm used
– salt used
– cost used
– hash itself
"$2y$10$Pa2cIqH5X3m6iqIYVDBdvOUcggnXnZzBy0dlie4VR...
20. Generators internally
./bin/php55 --rc Generator
Class [ <internal:Core> <iterateable> final class Generator
implements Iterator, Traversable ] { (...)
var_dump(new Generator);
Catchable fatal error: The "Generator" class is reserved for
internal use and cannot be manually instantiated
21. Generators deeper
● Generators can throw exceptions
● Generators can send() values
final class Generator implements Iterator {
void rewind();
bool valid();
mixed current();
mixed key();
void next();
mixed send(mixed $value);
mixed throw(Exception $exception);
}
25. "Other" changes
● ext/intl has been massively worked on / improved
● ext/curl up to date with new libcurl
● bison < 2.4 no longer supported (parser)
● libpcre and libgd updated
● array_column()
● cli_set_process_title()
● Lots of bug fixes
27. foreach() changes
● Foreach now supports list()
● Good to iterate over 2-dim arrays
$users = array(
array('Foo', 'Bar'),
array('Baz', 'Qux');
);
// Before
foreach ($users as $user) {
list($firstName, $lastName) = $user;
echo "First name: $firstName, last name: $lastName. ";
}
// After
foreach ($users as list($firstName, $lastName)) {
echo "First name: $firstName, last name: $lastName. ";
}
28. foreach() changes
● Foreach now accepts keys as non-scalars
● Iterators' key() may now return arrays
$it = new MultipleIterator();
$it->attachIterator(new ArrayIterator(array(1,2,3)));
$it->attachIterator(new ArrayIterator(array(4,5,6)));
foreach ($it as $k => $v) {
var_dump($k, $v); // $k is an array
}
30. boolval()
● We could cast to (bool), but there were no
function for that
– Those functions exist for other types
● intval(), strval(), floatval()
– A new function is to be used as a callback argument
var_dump( (boolval) "foo" ); // true
$data = [ 'foo', 42, false, new stdClass() ];
var_dump(array_map('boolval', $data));
31. Class name runtime resolution
● Resolve the FQN of an imported class
<?php
use vendorBBCBar;
class FooTest extends PHPUnit_Framework_TestCase
{
public function testExample()
{
$bar = $this->getMock(Bar::CLASS); // "vendorBBCBar"
/* … */
}
}
32. OPCache
● OPCache = "ZendOptimizerPlus" for PHP
– It's been freed by Zend recently
– It's then been renamed
● OPCache will be shipped with PHP 5.5 , as
a bundled extension you have to activate at
runtime
● http://www.php.net/opcache (wip)
● APC is now dead
34. OPCache vs APC
● APC
– Is (very) hard to maintain
– is maintained by few volunteers
● And it's been a PITA with 5.4
– Never do that again
– suffers from historical bad low-level designs
that make it very hard to evolve
– is less performant than OPCache, 5 to 20%
– provides a "user cache", OPCache doesn't
● ext/apcu is a possible candidate for that
35. OPCache vs APC
● OPCache
– Is PHP licenced (like APC)
– is maintained by volunteers
– is also maintained by pro guys, mainly hired by Zend
– will be maintained in the same time as PHP
● No more surprise like 5.4 and APC
– has been the first PHP OPcode cache
implementation (1998). Very mature
– Supports PHP from 5.2 to current (like APC)
– Integrates an optimizer
37. PHP 5.5 compatibility breaks
● ext/mysql has been deprecated /!
● /e modifier for preg() has been deprecated
● Dropped support for Windows XP and 2k3
● No more php logo and zend logo functions
● pack()/unpack() minor changes
● No more curl-wrappers
38. Performances ?
● The biggest step was 5.3 to 5.4
– First time for such a boost
● 5.5 is faster than 5.4
– But don't expect the same effect than 5.3 to 5.4