• Save
Php in 2013 (Web-5 2013 conference)
Upcoming SlideShare
Loading in...5
×
 

Php in 2013 (Web-5 2013 conference)

on

  • 1,898 views

Php in 2013 (Web-5 2013 conference) , from 1995 to 2013.

Php in 2013 (Web-5 2013 conference) , from 1995 to 2013.
Foresee PHP 5.5

Statistics

Views

Total Views
1,898
Views on SlideShare
1,887
Embed Views
11

Actions

Likes
1
Downloads
0
Comments
0

2 Embeds 11

http://lanyrd.com 7
https://twitter.com 4

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Php in 2013 (Web-5 2013 conference) Php in 2013 (Web-5 2013 conference) Presentation Transcript

  • PHP in 2013PHPs story to nowadays
  • Hello● Hello, Im Julien PAULI– PHP 5.5 Release Manager– Working for blablacar in Paris (www.blablacar.com)– Working with PHP since ~10y– Working on PHP internals ~3y
  • PHP Evolution
  • PHPs history● 1995
  • 1995 : CGIdata = getenv("QUERY_STRING");if(data && *data) {params = data; dest = data;while(*data) {if(*data==+) *dest= ;else if(*data == % && ishex(*(data+1))&&ishex(*(data+2))) {*dest = (char) htoi(data + 1);data+=2;} else *dest = *data;data++; dest++;}*dest = 0; s = strtok(params,"&");do {tmp = strchr(s,=);if(tmp) {*tmp = 0;if(!strcmp(s,"name")) name = tmp+1;else if(!strcmp(s,"age")) age = tmp+1;}} while(s=strtok(NULL,"&"));printf("Hi %s, you are %s years oldn",name,age);}
  • Complex stuff
  • Better stuff<html><head><title>Form Example</title></head><body><h1>My Example Form</h1><form action="form.phtml" method="POST">Name: <input type="text" name="name">Age: <input type="text" name="age"><br><input type="submit"></form><?if($name):?>Hi <?echo $name?>, you are <?echo $age?> years old<?endif?></body></html>
  • First PHPs● PHP 1 then 2 and PHP 3● 1998● Who still remembers PHP 3 ?
  • Refresh your mind !● Go and get it !● http://museum.php.net
  • PHP 4● 2000● sessions● Better extensions management● Zend Engine– Compilation
  • Zend Engine● Zeev Suraski● Andi Gutmans● Total rewrite of PHP3● Introduction of a compilation/execution engine● Performances
  • PHP 5● Zend Engine 2 (improved from 1, yep)– New OO model (true model)● 5.0 (2004)● 5.1 (2005)● 5.2 (2006)● 5.3 (2009)● 5.4 (2011)● 5.5 (2013)
  • PHP release process● Starting from 5.4, we have a 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
  • PHP Ecosystem● Read/improve the doc– www.php.net– edit.php.net● Develop– wiki.php.net– bugs.php.net– git.php.net / pecl.php.net– lxr.php.net● Improve quality– qa.php.net– bugs.php.net● Download– snaps.php.net– museum.php.net
  • Source distributions● We use Git– http://git.php.net● We mirror on Github– Social coding– New ideas– Pull Requests
  • PHP contributors● About 10 to 15 active people● Lots more total● Contribute on– Code (new features, changes, bugs&fixes)– Doc & translations– Infra services (hosting php.net worldwide)– Human management– … lots of things to do
  • PHP 5.5
  • PHP 5.5 new features● Password hashing API● "Finally" keyword● Generators● Syntax and engine improvements● Breaks, deprecations● … more not reported here
  • New Password hashing API● PHP users dont really understand/careabout the concept behing hashing, saltingand crypting● PHP doesnt give any hints about that● User are left on their own– Until 5.5 version– Welcome a new password hashing API !
  • New Password hashing API● https://wiki.php.net/rfc/password_hash● See how easy that looks now :– To generate a hash$password = secret;$hash = password_hash($password, PASSWORD_DEFAULT);var_dump($hash);// "$2y$10$Pa2cIqH5X3m6iqIYVDBdvOUcggnXnZzBy0dlie4VRHLr3ncLcyB7a"
  • New Password hashing API● https://wiki.php.net/rfc/password_hash● See how easy that looks now :– To verify a hash$provided_password = secret;$hash = "$2y$10$Pa2cIqH5X3m6iqIYVDBdvOUcggnXnZzBy0dlie4VRHLr3ncLcyB7a";if (password_verify($provided_password, $hash)) {echo "you are welcome" ;}
  • 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") ) ;
  • 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...
  • 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 updated● array_column()● cli_set_process_title()● Lots of bug fixes
  • Engine changes
  • foreach() changes● Foreach now supports list()● https://wiki.php.net/rfc/foreachlist$users = array(array(Foo, Bar),array(Baz, Qux););// Beforeforeach ($users as $user) {list($firstName, $lastName) = $user;echo "First name: $firstName, last name: $lastName. ";}// Afterforeach ($users as list($firstName, $lastName)) {echo "First name: $firstName, last name: $lastName. ";}
  • Array dereferencing strings● Dereference const expressions● https://wiki.php.net/rfc/constdereferencevar_dump( "php"[1] ); // hvar_dump( [1, 2, 3][1] ); // 2var_dump( [ [foo, bar], [1, 2] ] [0][1] ); // "bar"
  • OPCache● OPCache = "ZendOptimizerPlus" for PHP– Its been freed by Zend recently– Its then been renamed● OPCache will be shipped with PHP 5.5 , asan extension you have to activate at compiletime– it will be maintained together with PHP itself● APC is now dead
  • OPCache roles● OPCode caching + optimizing
  • Breaks
  • 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
  • Performances ?● The biggest step was 5.3 to 5.4– First time for such a boost● 5.5 is faster than 5.4– But dont expect the same effect than 5.3 to 5.4
  • Performances● Testing blablacar.com– PHPUnit 3.7.21– 959 tests– (Lots of external services and SQL)Time: 14:32, Memory: 1202.50MbTime: 12:48, Memory: 995.50MbTime: 12:30, Memory: 996.50Mb5.3.latest5.4.latest5.5.latest
  • Engine performance● PHP 5.3.latestempty_loop 0.161func() 0.459 0.298undef_func() 0.469 0.309int_func() 0.446 0.285$x = self::$x 0.444 0.284self::$x = 0 0.441 0.281isset(self::$x) 0.431 0.270empty(self::$x) 0.443 0.283$x = Foo::$x 0.586 0.425Foo::$x = 0 0.808 0.647isset(Foo::$x) 0.578 0.417empty(Foo::$x) 0.590 0.429self::f() 0.716 0.555Foo::f() 0.752 0.591$x = $this->x 0.426 0.265$this->x = 0 0.497 0.337$this->x += 2 0.439 0.279++$this->x 0.381 0.220--$this->x 0.404 0.244$this->x++ 0.411 0.251$this->x-- 0.415 0.254isset($this->x) 0.423 0.263empty($this->x) 0.433 0.272$this->f() 0.610 0.449$x = Foo::TEST 0.353 0.193new Foo() 1.763 1.602$x = TEST 0.371 0.211$x = $_GET 0.361 0.200$x = $GLOBALS[v] 0.501 0.341$x = $hash[v] 0.355 0.194$x = $str[0] 0.660 0.499$x = $a ?: null 2.139 1.978$x = $f ?: tmp 0.435 0.274$x = $f ? $f : $a 2.141 1.980$x = $f ? $f : tmp 0.418 0.258Total 21.259
  • Engine performance● PHP 5.4.latestempty_loop 0.117func() 0.380 0.263undef_func() 0.377 0.260int_func() 0.336 0.219$x = self::$x 0.361 0.245self::$x = 0 0.331 0.214isset(self::$x) 0.232 0.116empty(self::$x) 0.243 0.127$x = Foo::$x 0.327 0.210Foo::$x = 0 0.217 0.100isset(Foo::$x) 0.279 0.162empty(Foo::$x) 0.216 0.100self::f() 0.398 0.281Foo::f() 0.365 0.248$x = $this->x 0.363 0.246$this->x = 0 0.322 0.205$this->x += 2 0.252 0.136++$this->x 0.220 0.103--$this->x 0.224 0.107$this->x++ 0.248 0.132$this->x-- 0.252 0.135isset($this->x) 0.232 0.115empty($this->x) 0.251 0.135$this->f() 0.423 0.307$x = Foo::TEST 0.220 0.103new Foo() 0.821 0.705$x = TEST 0.169 0.052$x = $_GET 0.256 0.140$x = $GLOBALS[v] 0.450 0.334$x = $hash[v] 0.355 0.238$x = $str[0] 0.369 0.252$x = $a ?: null 0.235 0.118$x = $f ?: tmp 0.330 0.213$x = $f ? $f : $a 0.245 0.129$x = $f ? $f : tmp 0.334 0.217Total 10.749
  • Engine performance● PHP 5.5.latestempty_loop 0.117func() 0.396 0.279undef_func() 0.415 0.298int_func() 0.325 0.208$x = self::$x 0.286 0.169self::$x = 0 0.399 0.282isset(self::$x) 0.237 0.120empty(self::$x) 0.282 0.165$x = Foo::$x 0.246 0.129Foo::$x = 0 0.320 0.203isset(Foo::$x) 0.203 0.086empty(Foo::$x) 0.248 0.131self::f() 0.433 0.316Foo::f() 0.395 0.278$x = $this->x 0.249 0.132$this->x = 0 0.320 0.203$this->x += 2 0.251 0.134++$this->x 0.309 0.192--$this->x 0.223 0.106$this->x++ 0.248 0.131$this->x-- 0.258 0.141isset($this->x) 0.236 0.119empty($this->x) 0.262 0.145$this->f() 0.438 0.321$x = Foo::TEST 0.225 0.107new Foo() 0.825 0.708$x = TEST 0.177 0.060$x = $_GET 0.262 0.145$x = $GLOBALS[v] 0.357 0.240$x = $hash[v] 0.267 0.150$x = $str[0] 0.368 0.251$x = $a ?: null 0.233 0.115$x = $f ?: tmp 0.317 0.200$x = $f ? $f : $a 0.254 0.137$x = $f ? $f : tmp 0.318 0.201Total 10.700
  • Thank you for listening !