SlideShare une entreprise Scribd logo
1  sur  48
PHP5.4 | PHPTour Lille 2011   1




PHP 5.4 arrive...
PHP5.4 | PHPTour Lille 2011   2


             Hello, I'm Julien Pauli :)
@julienpauli
   http://julien-pauli.developpez.com



IRC Freenode, EFNet
   @jpauli

Software architect – PHP Guru
Working at Comuto
   http://www.covoiturage.fr

OSS Contributor
   PHP Contributor – http://doc.php.net/fr
   jpauli@php.net
PHP5.4 | PHPTour Lille 2011   3


        Orateur prévu : David Soria Parra


From: David Soria Parra
To: communication / AFUP

Hello,

I'm very very sorry, but I have to cancel my talk on Thursday. I'm
sick and have to stay at home for the week. This is the first time I
have to cancel a talk at all and I'm very very sorry for it.

[...]
PHP5.4 | PHPTour Lille 2011   4


On va parler de PHP
PHP5.4 | PHPTour Lille 2011   5

                PHP & PHP 5.4 ?
PHP : Une belle histoire (historique)

Aujourd'hui : la communauté évolue
   Un nouveau processus de contribution
   De nouveaux canaux de développement
   Une nouvelle timeline de distribution

Nouveautés techniques
   Performances
   Fonctionnalités

Conclusion
PHP5.4 | PHPTour Lille 2011   6


                  Historique
1995 : PHP 1.0
1998 : PHP 3.0
2000 : PHP 4.0
2004 : PHP 5.0
2009 : PHP 5.3
2011 : PHP 5.4


PHP 6 ?


http://museum.php.net
PHP5.4 | PHPTour Lille 2011   7


                           Aujourd'hui :


“All PHP users should note that the PHP 5.2 series is NOT supported anymore.”

                                                              http://www.php.net
PHP5.4 | PHPTour Lille 2011   8




La communauté évolue
         -
      Les RFC
PHP5.4 | PHPTour Lille 2011   9


                                   RFC
       Une idée pour améliorer PHP ?

       Publier une RFC
       La réfléchir, la mûrir
       Publier des patchs, des squelettes
          Les mûrir
       Faire voter la RFC
          https://wiki.php.net/rfc/voting
"There's no way around this 'small' issue. Changes made to the PHP language
will affect millions of people, and theoretically, each and every one
of them should have a say in what we do. For obvious reasons, though,
this isn't a practical approach."

                                                     https://wiki.php.net/rfc/voting
PHP5.4 | PHPTour Lille 2011   10


          Requests For Comments
https://wiki.php.net/rfc
PHP5.4 | PHPTour Lille 2011   11




Nouveau processus de publication
               -
        Release process
PHP5.4 | PHPTour Lille 2011    12


           Nouveau processus de publication


“PHP releases have always been done spontaneously, in a somehow
chaotic way. Individual(s) decided when a release will happen and what could
or could fit in. Release managers role are unclear and the way to nominate
them is not clearly defined either.

The goals of this RFC aim to solve these issues while giving to us, our users
and 3rd parties (distributions, contributors, etc.) more visibility and the ability
to actually have a roadmap, or plan developments.”
                                                            https://wiki.php.net/rfc/releaseprocess
PHP5.4 | PHPTour Lille 2011   13


         Un calendrier plus précis
Une durée de vie de 3 ans
  Une mineure par an
PHP5.4 | PHPTour Lille 2011   14


      Un calendrier compréhensif
2 majeures peuvent cohéxister
  Comme PHP4 & PHP5 à leur époque
  Simplifier les migrations
PHP5.4 | PHPTour Lille 2011   15


On ne casse pas tout
             Majeures (PHP 5)
                BC breaks possibles

             Mineures (PHP 5.4)
                nouvelles fonctionnalités
                Mouvements d'extensions
                (PECL ↔ Core)
                Pas de BC break

             Révisions (PHP 5.4.1)
                Bug fixes seulement
PHP5.4 | PHPTour Lille 2011   16


  Nouveau processus de publication
https://wiki.php.net/rfc/releaseprocess
PHP5.4 | PHPTour Lille 2011   17




Un nouveau processus de développement
PHP5.4 | PHPTour Lille 2011   18




Un nouveau processus de développement
PHP5.4 | PHPTour Lille 2011   19


                   PHP passe à Git
24/12/2011
   Passage à Git

Serveur git hebergé sur php.net
   Pour des raisons de sécurité et de gestion des utilisateurs

Mirroir sur github



Byebye SVN
PHP5.4 | PHPTour Lille 2011   20




PHP 5.4 : nouveautés techniques
PHP5.4 | PHPTour Lille 2011   21


        PHP 5.4, un peu de ménage
Dites au revoir à :

   safe_mode
   register_globals, import_request_variables()
   register_long_arrays
   allow_call_time_pass_reference ( foo(&$bar) )
   y2k_compliance
   magic_quotes***
   session_register(), session_unregister(),
   session_is_registered()
   ext/sqlite
PHP5.4 | PHPTour Lille 2011   22


          PHP 5.4, ajouts en vrac
new ReflectionZendExtension
new SessionHandler

Compatibilité avec autoconf 2.59+ (obligatoire)

MySQLnd activé par défaut (et non plus libmysql)

http_response_code()
session_status()
ReflectionClass::newInstanceWithoutConstructor()

Dtrace support (mac & Solaris)
E_ALL contient E_STRICT ;-)
PHP5.4 | PHPTour Lille 2011   23




Le meilleur de PHP 5.4 … ??
PHP5.4 | PHPTour Lille 2011   24




Performances !!

(~+55% bruts)
PHP5.4 | PHPTour Lille 2011   25


               Performances de PHP5.4
La plus belle amélioration de PHP 5.4 est sous le manteau
   http://svn.php.net/viewvc/php/php-src/branches/PHP_5_4/NEWS

- Improved Zend Engine, performance tweaks and optimizations: (Dmitry)
  . Inlined most probable code-paths for arithmetic operations directly into
    executor.
  . Eliminated unnecessary iterations during request startup/shutdown.
  . Changed $GLOBALS into a JIT autoglobal, so it's initialized only if used.
    (this may affect opcode caches!)
  . Improved performance of @ (silence) operator.
  . Simplified string offset reading. $str[1][0] is now a legal construct.
  . Added caches to eliminate repeatable run-time bindings of functions,
    classes, constants, methods and properties.
  . Added concept of interned strings. All strings constants known at compile
    time are allocated in a single copy and never changed.
  . Added an optimization which saves memory and emalloc/efree calls for empty
    HashTables. (Stas, Dmitry)
[...]
PHP5.4 | PHPTour Lille 2011   26


PHP 5.4,micro-bench
  <--PHP 5.3 : 25.8 sec


  PHP 5.4 : 9.9sec →


  Micro bench dispo sur svn
PHP5.4 | PHPTour Lille 2011   27


           PHP 5.4, essai PHPUnit
Lançons la suite de tests de Symfony2
   Symfony2 master
   PHPUnit 3.6.3
PHP5.4 | PHPTour Lille 2011   28


         PHP 5.4 – sort open tags
<?= est toujours disponible quel que soit le niveau de
sort_open_tags




                  <?= $foo; ?>
PHP5.4 | PHPTour Lille 2011   29


                Serveur web embarqué
Pas pour de la production ;-)
   Possibilité d'utiliser un routeur (script PHP)
http://www.php.net/manual/fr/features.commandline.webserver.php
PHP5.4 | PHPTour Lille 2011   30


                        Callable
Nouveau typage : "callable"
   "callable" devient donc un mot reservé

   class PubSub {
      // code......
      public function subscribe($name, callable $cb) {
          if (!isset($this->callbacks[$name])) {
               $this->callbacks[$name] = array();
          }
          $this->callbacks[$name] = $cb;
      }
   }

   $ps = new PubSub();
   $ps->subscribe('foo', function() { echo 'test'; });
   $ps->subscribe('foo', 'bla'); // catchable fatal error
PHP5.4 | PHPTour Lille 2011   31


       Qu'est ce qui est "callable" ?
Toute callback PHP :
   'some-existing-function'
   array($someobj, 'some-public-method')
   array('someClass', 'some-static-public-method')
   function () { };

Notez cette nouvelle procédure d'invocation :
 class Hello {
    public function world($x) { return "hello $x"; }
 }

 $f = array(new Hello, 'world');

 var_dump($f('foo')); // hello foo
PHP5.4 | PHPTour Lille 2011   32


             Short Array Syntax
Python or Javascript anyone ?

$cfg = array('loglevel' => 3,
             'database' => array('username' => 'foo',
                                 'password' => 'secret')
             );




$cfg = ['loglevel' => 3,
              'database' => ['username' => 'foo',
                             'password' => 'secret']
      ];
PHP5.4 | PHPTour Lille 2011   33


             Arrays dereferencing
Oui, ça c'était très attendu ...


function foo() {
   return array('foo'=>'bar');
}

$var = foo()['foo'];
PHP5.4 | PHPTour Lille 2011   34


           "new" fluent interface
On aime, on n'aime pas, on aime peut-être ...




    $obj = (new MyClass)->someMethod();
PHP5.4 | PHPTour Lille 2011   35


Invocations statiques dynamiques




        echo Bar::{'foo'}();
PHP5.4 | PHPTour Lille 2011   36


                            WTF ? OMG !
       I love that
           (I really do)

class Foo {
   public static function bar() {
       return ['wtf'];
   }
   public function wtf() {
       return 'omg';
   }
}

$meth = 'bar';

var_dump( (new Foo)->{Foo::$meth()[0]}() ); // omg
PHP5.4 | PHPTour Lille 2011   37


   Notation binaire pour les entiers
C'est vrai que ça manquait ;-)
   0b



 var_dump( 0b1010 + (0b01<<2) ); // 14


   http://julien-pauli.developpez.com/tutoriels/php/bool-op/
PHP5.4 | PHPTour Lille 2011   38


                          Traits
Mixins, héritage horizontal, héritage multiple
   Appelez-les comme vous voulez
   Aimez-les, ou pas …
http://www.php.net/traits

           trait ToArray {
                public function toArray() {
                   return $this->array;
               }
           }
PHP5.4 | PHPTour Lille 2011   39


                                   Traits
                      trait ToArray {
                          public function toArray() {
                              return $this->array;
                         }
                      }


class MainConfig {                           class Config extends MainConfig {
   private $array = ['foo'];                    use ToArray;
   public function config() { }                 private $array = ['bar'];
}                                            }




                     $config = new Config;
                     echo $config->toArray()[0]; // bar
PHP5.4 | PHPTour Lille 2011   40


                                Closures
        Les closures supportent (enfin) $this
           Byebye $that et autres $self

class A {
   private $value = 1;

    function firstGetter($name) {
      return function() use ($name) {     $a = new A();
         return $this->$name;             $firstGetter = $a->firstGetter('value');
      };                                  echo $firstGetter(); // 1
    }                                     $secondGetter = $a->secondGetter();
    function secondGetter($name) {        echo $secondGetter('value'); //1
      return function($name) {
         return $this->$name;
      };
    }
}
PHP5.4 | PHPTour Lille 2011   41


                    Domaine des closures
       Suite au support de $this, les closures peuvent maintenant
       changer de domaine

class A {                         $a = new A;
   private $value = 1;            $b = new B;

  function getter() {             $closureA = $a->getter();
    return function() {           echo $closureA(); // 2
       return ++$this->value;};
  }                               $closureB = $closureA->bindTo($b, $b);
}                                 echo $closureB(); // 43
class B extends A {
   private $value = 42;
}
PHP5.4 | PHPTour Lille 2011   42


                       JSONSerializable
     Nouvelle interface
         Fonctionnement "à la __toString()"



class Foo implements JsonSerializable {
    private $name = 'PHP';

    public function jsonSerialize() {
       return "I love $this->name";
    }

}

echo json_encode(new Foo);
PHP5.4 | PHPTour Lille 2011   43




PHP a besoin de vous !
PHP5.4 | PHPTour Lille 2011   44


          Aidez-nous à tester PHP
Compilez, make test, et envoyez vos résultats

Lancez vos suites de tests sous PHP 5.4
   Et faites nous suivre vos remarques

Participez à l'élaboration de la documentation
   http://edit.php.net
   Présentation demain 11h45, salle 2, Yannick Torres
PHP5.4 | PHPTour Lille 2011   45


          Aidez-nous à tester PHP
Compilez, make test, et envoyez vos résultats

   http://qa.php.net/reports/?version=5.4.0RC1
   http://gcov.php.net/viewer.php?version=PHP_5_4

Lancez vos suites de tests sous PHP 5.4
   Et faites nous suivre vos remarques

Participez à l'élaboration de la documentation
   http://edit.php.net
   Présentation demain 11h45, salle 2, Yannick Torres
PHP5.4 | PHPTour Lille 2011   46


                 Ressources, infos
PHP 5.4 : 2011
   Décembre ? Cadeau de Noël ?
   On est en RC2 pour le moment

http://www.php.net/manual/fr/migration54.php
   En cours d’élaboration

https://wiki.php.net/todo/php54


Toutes les RFC en cours :
   https://wiki.php.net/rfc
PHP5.4 | PHPTour Lille 2011   47


                       Merci !
Merci à la communauté PHP
Merci à ses contributeurs
   Felipe Pena, Etienne Kneuss, Stanislav Malyshev, Gustavo
   André dos Santos Lopes, David Soria Parra, Christian
   Stocker, Rob Richards, Pierre Joye, Zeev Suraski, Ilia
   Alshanetsky […]

Merci à vous !



Nous recrutons :)
   Passez me voir
PHP5.4 | PHPTour Lille 2011   48


                    Questions ?
Chattez avec David Soria Parra
   De 12h30 à 14h
   IRC Freenode #phptour
   http://webchat.freenode.net

Contenu connexe

Tendances

PHP #1 : introduction
PHP #1 : introductionPHP #1 : introduction
PHP #1 : introductionJean Michel
 
PHP 5.3, PHP Next
PHP 5.3, PHP NextPHP 5.3, PHP Next
PHP 5.3, PHP NextSQLI
 
Formation PHP
Formation PHPFormation PHP
Formation PHPkemenaran
 
PHP 7.0 : aperçu des nouveautés
PHP 7.0 : aperçu des nouveautésPHP 7.0 : aperçu des nouveautés
PHP 7.0 : aperçu des nouveautésDidcode
 
Php 7.4 2020-01-28 - afup
Php 7.4   2020-01-28 - afupPhp 7.4   2020-01-28 - afup
Php 7.4 2020-01-28 - afupJulien Vinber
 
PHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_ExtensionsPHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_Extensionsjulien pauli
 
Migration PHP4-PHP5
Migration PHP4-PHP5Migration PHP4-PHP5
Migration PHP4-PHP5julien pauli
 
PHP 5.3 : les nouveautés du futur si proche
PHP 5.3 : les nouveautés du futur si prochePHP 5.3 : les nouveautés du futur si proche
PHP 5.3 : les nouveautés du futur si prochePascal MARTIN
 
Monitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et PinbaMonitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et PinbaPatrick Allaert
 
Zend Framework 2
Zend Framework 2Zend Framework 2
Zend Framework 2epixelic
 
Cours php & Mysql - 1ére partie
Cours php & Mysql - 1ére partieCours php & Mysql - 1ére partie
Cours php & Mysql - 1ére partiekadzaki
 
Introduction au langage PHP (2éme partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (2éme partie) élaborée par Marouan OMEZZINEIntroduction au langage PHP (2éme partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (2éme partie) élaborée par Marouan OMEZZINEMarouan OMEZZINE
 

Tendances (19)

PHP #1 : introduction
PHP #1 : introductionPHP #1 : introduction
PHP #1 : introduction
 
PHP 5.3, PHP Next
PHP 5.3, PHP NextPHP 5.3, PHP Next
PHP 5.3, PHP Next
 
Formation PHP
Formation PHPFormation PHP
Formation PHP
 
PHP 7.0 : aperçu des nouveautés
PHP 7.0 : aperçu des nouveautésPHP 7.0 : aperçu des nouveautés
PHP 7.0 : aperçu des nouveautés
 
Php 7.4 2020-01-28 - afup
Php 7.4   2020-01-28 - afupPhp 7.4   2020-01-28 - afup
Php 7.4 2020-01-28 - afup
 
Cours php
Cours phpCours php
Cours php
 
Cours php
Cours phpCours php
Cours php
 
Php & My Sql
Php & My SqlPhp & My Sql
Php & My Sql
 
Php 5.3
Php 5.3Php 5.3
Php 5.3
 
PHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_ExtensionsPHPTour-2011-PHP_Extensions
PHPTour-2011-PHP_Extensions
 
Formation python 3
Formation python 3Formation python 3
Formation python 3
 
Migration PHP4-PHP5
Migration PHP4-PHP5Migration PHP4-PHP5
Migration PHP4-PHP5
 
PHP 5.3 : les nouveautés du futur si proche
PHP 5.3 : les nouveautés du futur si prochePHP 5.3 : les nouveautés du futur si proche
PHP 5.3 : les nouveautés du futur si proche
 
Monitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et PinbaMonitoring d'applications/environnements PHP: APM et Pinba
Monitoring d'applications/environnements PHP: APM et Pinba
 
Php cours
Php coursPhp cours
Php cours
 
Playing With PHP 5.3
Playing With PHP 5.3Playing With PHP 5.3
Playing With PHP 5.3
 
Zend Framework 2
Zend Framework 2Zend Framework 2
Zend Framework 2
 
Cours php & Mysql - 1ére partie
Cours php & Mysql - 1ére partieCours php & Mysql - 1ére partie
Cours php & Mysql - 1ére partie
 
Introduction au langage PHP (2éme partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (2éme partie) élaborée par Marouan OMEZZINEIntroduction au langage PHP (2éme partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (2éme partie) élaborée par Marouan OMEZZINE
 

Similaire à PHPTour 2011 - PHP5.4

Présentation de PHP 5.4 [FR]
Présentation de PHP 5.4 [FR]Présentation de PHP 5.4 [FR]
Présentation de PHP 5.4 [FR]Wixiweb
 
Cours IEF - Présentation de PHP
Cours IEF - Présentation de PHPCours IEF - Présentation de PHP
Cours IEF - Présentation de PHPRégis Lutter
 
Symfony 4 2019
Symfony 4 2019Symfony 4 2019
Symfony 4 2019Eric Para
 
BC Breaks - Incompatibilites PHP7
BC Breaks - Incompatibilites PHP7BC Breaks - Incompatibilites PHP7
BC Breaks - Incompatibilites PHP7Darkmira
 
Mieux Développer en PHP avec Symfony
Mieux Développer en PHP avec SymfonyMieux Développer en PHP avec Symfony
Mieux Développer en PHP avec SymfonyHugo Hamon
 
Tout pour se préparer à PHP 7.4
Tout pour se préparer à PHP 7.4Tout pour se préparer à PHP 7.4
Tout pour se préparer à PHP 7.4Damien Seguy
 
Cyphp5 p formation-php-5-perfectionnement-fonctions-avancees-et-programmation
Cyphp5 p formation-php-5-perfectionnement-fonctions-avancees-et-programmationCyphp5 p formation-php-5-perfectionnement-fonctions-avancees-et-programmation
Cyphp5 p formation-php-5-perfectionnement-fonctions-avancees-et-programmationCERTyou Formation
 
hassclic270.ppt
hassclic270.ppthassclic270.ppt
hassclic270.pptadiouf2
 
AlterWay SolutionsLinux Outils Industrialisation PHP
AlterWay SolutionsLinux Outils Industrialisation PHPAlterWay SolutionsLinux Outils Industrialisation PHP
AlterWay SolutionsLinux Outils Industrialisation PHPjulien pauli
 
Cyphp5 w formation-php-5-l-essentiel-de-php-pour-developper-un-site-web
Cyphp5 w formation-php-5-l-essentiel-de-php-pour-developper-un-site-webCyphp5 w formation-php-5-l-essentiel-de-php-pour-developper-un-site-web
Cyphp5 w formation-php-5-l-essentiel-de-php-pour-developper-un-site-webCERTyou Formation
 
Apache for développeurs PHP
Apache for développeurs PHPApache for développeurs PHP
Apache for développeurs PHPjulien pauli
 
Industrialiser le contrat dans un projet PHP
Industrialiser le contrat dans un projet PHPIndustrialiser le contrat dans un projet PHP
Industrialiser le contrat dans un projet PHPhalleck45
 
Conference drupal 8 au Forum PHP 2013 à Paris
Conference drupal 8 au Forum PHP 2013 à ParisConference drupal 8 au Forum PHP 2013 à Paris
Conference drupal 8 au Forum PHP 2013 à ParisChipway
 
PHP Tour 2012 - Conférence FuelPHP
PHP Tour 2012 - Conférence FuelPHPPHP Tour 2012 - Conférence FuelPHP
PHP Tour 2012 - Conférence FuelPHPNovius OS
 

Similaire à PHPTour 2011 - PHP5.4 (20)

Présentation de PHP 5.4 [FR]
Présentation de PHP 5.4 [FR]Présentation de PHP 5.4 [FR]
Présentation de PHP 5.4 [FR]
 
Cours IEF - Présentation de PHP
Cours IEF - Présentation de PHPCours IEF - Présentation de PHP
Cours IEF - Présentation de PHP
 
Symfony 4 2019
Symfony 4 2019Symfony 4 2019
Symfony 4 2019
 
BC Breaks - Incompatibilites PHP7
BC Breaks - Incompatibilites PHP7BC Breaks - Incompatibilites PHP7
BC Breaks - Incompatibilites PHP7
 
Mieux Développer en PHP avec Symfony
Mieux Développer en PHP avec SymfonyMieux Développer en PHP avec Symfony
Mieux Développer en PHP avec Symfony
 
Lp web tp3_idse
Lp web tp3_idseLp web tp3_idse
Lp web tp3_idse
 
PHP5: Endgame
PHP5: EndgamePHP5: Endgame
PHP5: Endgame
 
Tout pour se préparer à PHP 7.4
Tout pour se préparer à PHP 7.4Tout pour se préparer à PHP 7.4
Tout pour se préparer à PHP 7.4
 
Nouveautés php 7
Nouveautés php 7Nouveautés php 7
Nouveautés php 7
 
Cyphp5 p formation-php-5-perfectionnement-fonctions-avancees-et-programmation
Cyphp5 p formation-php-5-perfectionnement-fonctions-avancees-et-programmationCyphp5 p formation-php-5-perfectionnement-fonctions-avancees-et-programmation
Cyphp5 p formation-php-5-perfectionnement-fonctions-avancees-et-programmation
 
hassclic270.ppt
hassclic270.ppthassclic270.ppt
hassclic270.ppt
 
PHP & Initiation Symfony
PHP & Initiation SymfonyPHP & Initiation Symfony
PHP & Initiation Symfony
 
AlterWay SolutionsLinux Outils Industrialisation PHP
AlterWay SolutionsLinux Outils Industrialisation PHPAlterWay SolutionsLinux Outils Industrialisation PHP
AlterWay SolutionsLinux Outils Industrialisation PHP
 
Cyphp5 w formation-php-5-l-essentiel-de-php-pour-developper-un-site-web
Cyphp5 w formation-php-5-l-essentiel-de-php-pour-developper-un-site-webCyphp5 w formation-php-5-l-essentiel-de-php-pour-developper-un-site-web
Cyphp5 w formation-php-5-l-essentiel-de-php-pour-developper-un-site-web
 
Apache for développeurs PHP
Apache for développeurs PHPApache for développeurs PHP
Apache for développeurs PHP
 
Industrialiser le contrat dans un projet PHP
Industrialiser le contrat dans un projet PHPIndustrialiser le contrat dans un projet PHP
Industrialiser le contrat dans un projet PHP
 
Conference drupal 8 au Forum PHP 2013 à Paris
Conference drupal 8 au Forum PHP 2013 à ParisConference drupal 8 au Forum PHP 2013 à Paris
Conference drupal 8 au Forum PHP 2013 à Paris
 
PHP Tour 2012 - Conférence FuelPHP
PHP Tour 2012 - Conférence FuelPHPPHP Tour 2012 - Conférence FuelPHP
PHP Tour 2012 - Conférence FuelPHP
 
Fuel php nantes 2012
Fuel php nantes 2012Fuel php nantes 2012
Fuel php nantes 2012
 
Compte rendu Blend Web Mix 2015
Compte rendu Blend Web Mix 2015Compte rendu Blend Web Mix 2015
Compte rendu Blend Web Mix 2015
 

Plus de julien pauli

Doctrine with Symfony - SymfonyCon 2019
Doctrine with Symfony - SymfonyCon 2019Doctrine with Symfony - SymfonyCon 2019
Doctrine with Symfony - SymfonyCon 2019julien pauli
 
PHP 7 OPCache extension review
PHP 7 OPCache extension reviewPHP 7 OPCache extension review
PHP 7 OPCache extension reviewjulien pauli
 
PHP Internals and Virtual Machine
PHP Internals and Virtual MachinePHP Internals and Virtual Machine
PHP Internals and Virtual Machinejulien pauli
 
Basics of Cryptography - Stream ciphers and PRNG
Basics of Cryptography - Stream ciphers and PRNGBasics of Cryptography - Stream ciphers and PRNG
Basics of Cryptography - Stream ciphers and PRNGjulien pauli
 
Mastering your home network - Do It Yourself
Mastering your home network - Do It YourselfMastering your home network - Do It Yourself
Mastering your home network - Do It Yourselfjulien pauli
 
SymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performancesSymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performancesjulien pauli
 
Php and threads ZTS
Php and threads ZTSPhp and threads ZTS
Php and threads ZTSjulien pauli
 
Symfony live 2017_php7_performances
Symfony live 2017_php7_performancesSymfony live 2017_php7_performances
Symfony live 2017_php7_performancesjulien pauli
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshopjulien pauli
 
Profiling php5 to php7
Profiling php5 to php7Profiling php5 to php7
Profiling php5 to php7julien pauli
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5julien 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
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshopjulien pauli
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objectsjulien pauli
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13julien pauli
 

Plus de julien pauli (20)

Doctrine with Symfony - SymfonyCon 2019
Doctrine with Symfony - SymfonyCon 2019Doctrine with Symfony - SymfonyCon 2019
Doctrine with Symfony - SymfonyCon 2019
 
Php engine
Php enginePhp engine
Php engine
 
PHP 7 OPCache extension review
PHP 7 OPCache extension reviewPHP 7 OPCache extension review
PHP 7 OPCache extension review
 
Dns
DnsDns
Dns
 
PHP Internals and Virtual Machine
PHP Internals and Virtual MachinePHP Internals and Virtual Machine
PHP Internals and Virtual Machine
 
Basics of Cryptography - Stream ciphers and PRNG
Basics of Cryptography - Stream ciphers and PRNGBasics of Cryptography - Stream ciphers and PRNG
Basics of Cryptography - Stream ciphers and PRNG
 
Mastering your home network - Do It Yourself
Mastering your home network - Do It YourselfMastering your home network - Do It Yourself
Mastering your home network - Do It Yourself
 
SymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performancesSymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performances
 
Php and threads ZTS
Php and threads ZTSPhp and threads ZTS
Php and threads ZTS
 
Tcpip
TcpipTcpip
Tcpip
 
Symfony live 2017_php7_performances
Symfony live 2017_php7_performancesSymfony live 2017_php7_performances
Symfony live 2017_php7_performances
 
PHP 7 new engine
PHP 7 new enginePHP 7 new engine
PHP 7 new engine
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshop
 
Profiling php5 to php7
Profiling php5 to php7Profiling php5 to php7
Profiling php5 to php7
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
 
Mysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extension
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshop
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objects
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 

PHPTour 2011 - PHP5.4

  • 1. PHP5.4 | PHPTour Lille 2011 1 PHP 5.4 arrive...
  • 2. PHP5.4 | PHPTour Lille 2011 2 Hello, I'm Julien Pauli :) @julienpauli http://julien-pauli.developpez.com IRC Freenode, EFNet @jpauli Software architect – PHP Guru Working at Comuto http://www.covoiturage.fr OSS Contributor PHP Contributor – http://doc.php.net/fr jpauli@php.net
  • 3. PHP5.4 | PHPTour Lille 2011 3 Orateur prévu : David Soria Parra From: David Soria Parra To: communication / AFUP Hello, I'm very very sorry, but I have to cancel my talk on Thursday. I'm sick and have to stay at home for the week. This is the first time I have to cancel a talk at all and I'm very very sorry for it. [...]
  • 4. PHP5.4 | PHPTour Lille 2011 4 On va parler de PHP
  • 5. PHP5.4 | PHPTour Lille 2011 5 PHP & PHP 5.4 ? PHP : Une belle histoire (historique) Aujourd'hui : la communauté évolue Un nouveau processus de contribution De nouveaux canaux de développement Une nouvelle timeline de distribution Nouveautés techniques Performances Fonctionnalités Conclusion
  • 6. PHP5.4 | PHPTour Lille 2011 6 Historique 1995 : PHP 1.0 1998 : PHP 3.0 2000 : PHP 4.0 2004 : PHP 5.0 2009 : PHP 5.3 2011 : PHP 5.4 PHP 6 ? http://museum.php.net
  • 7. PHP5.4 | PHPTour Lille 2011 7 Aujourd'hui : “All PHP users should note that the PHP 5.2 series is NOT supported anymore.” http://www.php.net
  • 8. PHP5.4 | PHPTour Lille 2011 8 La communauté évolue - Les RFC
  • 9. PHP5.4 | PHPTour Lille 2011 9 RFC Une idée pour améliorer PHP ? Publier une RFC La réfléchir, la mûrir Publier des patchs, des squelettes Les mûrir Faire voter la RFC https://wiki.php.net/rfc/voting "There's no way around this 'small' issue. Changes made to the PHP language will affect millions of people, and theoretically, each and every one of them should have a say in what we do. For obvious reasons, though, this isn't a practical approach." https://wiki.php.net/rfc/voting
  • 10. PHP5.4 | PHPTour Lille 2011 10 Requests For Comments https://wiki.php.net/rfc
  • 11. PHP5.4 | PHPTour Lille 2011 11 Nouveau processus de publication - Release process
  • 12. PHP5.4 | PHPTour Lille 2011 12 Nouveau processus de publication “PHP releases have always been done spontaneously, in a somehow chaotic way. Individual(s) decided when a release will happen and what could or could fit in. Release managers role are unclear and the way to nominate them is not clearly defined either. The goals of this RFC aim to solve these issues while giving to us, our users and 3rd parties (distributions, contributors, etc.) more visibility and the ability to actually have a roadmap, or plan developments.” https://wiki.php.net/rfc/releaseprocess
  • 13. PHP5.4 | PHPTour Lille 2011 13 Un calendrier plus précis Une durée de vie de 3 ans Une mineure par an
  • 14. PHP5.4 | PHPTour Lille 2011 14 Un calendrier compréhensif 2 majeures peuvent cohéxister Comme PHP4 & PHP5 à leur époque Simplifier les migrations
  • 15. PHP5.4 | PHPTour Lille 2011 15 On ne casse pas tout Majeures (PHP 5) BC breaks possibles Mineures (PHP 5.4) nouvelles fonctionnalités Mouvements d'extensions (PECL ↔ Core) Pas de BC break Révisions (PHP 5.4.1) Bug fixes seulement
  • 16. PHP5.4 | PHPTour Lille 2011 16 Nouveau processus de publication https://wiki.php.net/rfc/releaseprocess
  • 17. PHP5.4 | PHPTour Lille 2011 17 Un nouveau processus de développement
  • 18. PHP5.4 | PHPTour Lille 2011 18 Un nouveau processus de développement
  • 19. PHP5.4 | PHPTour Lille 2011 19 PHP passe à Git 24/12/2011 Passage à Git Serveur git hebergé sur php.net Pour des raisons de sécurité et de gestion des utilisateurs Mirroir sur github Byebye SVN
  • 20. PHP5.4 | PHPTour Lille 2011 20 PHP 5.4 : nouveautés techniques
  • 21. PHP5.4 | PHPTour Lille 2011 21 PHP 5.4, un peu de ménage Dites au revoir à : safe_mode register_globals, import_request_variables() register_long_arrays allow_call_time_pass_reference ( foo(&$bar) ) y2k_compliance magic_quotes*** session_register(), session_unregister(), session_is_registered() ext/sqlite
  • 22. PHP5.4 | PHPTour Lille 2011 22 PHP 5.4, ajouts en vrac new ReflectionZendExtension new SessionHandler Compatibilité avec autoconf 2.59+ (obligatoire) MySQLnd activé par défaut (et non plus libmysql) http_response_code() session_status() ReflectionClass::newInstanceWithoutConstructor() Dtrace support (mac & Solaris) E_ALL contient E_STRICT ;-)
  • 23. PHP5.4 | PHPTour Lille 2011 23 Le meilleur de PHP 5.4 … ??
  • 24. PHP5.4 | PHPTour Lille 2011 24 Performances !! (~+55% bruts)
  • 25. PHP5.4 | PHPTour Lille 2011 25 Performances de PHP5.4 La plus belle amélioration de PHP 5.4 est sous le manteau http://svn.php.net/viewvc/php/php-src/branches/PHP_5_4/NEWS - Improved Zend Engine, performance tweaks and optimizations: (Dmitry) . Inlined most probable code-paths for arithmetic operations directly into executor. . Eliminated unnecessary iterations during request startup/shutdown. . Changed $GLOBALS into a JIT autoglobal, so it's initialized only if used. (this may affect opcode caches!) . Improved performance of @ (silence) operator. . Simplified string offset reading. $str[1][0] is now a legal construct. . Added caches to eliminate repeatable run-time bindings of functions, classes, constants, methods and properties. . Added concept of interned strings. All strings constants known at compile time are allocated in a single copy and never changed. . Added an optimization which saves memory and emalloc/efree calls for empty HashTables. (Stas, Dmitry) [...]
  • 26. PHP5.4 | PHPTour Lille 2011 26 PHP 5.4,micro-bench <--PHP 5.3 : 25.8 sec PHP 5.4 : 9.9sec → Micro bench dispo sur svn
  • 27. PHP5.4 | PHPTour Lille 2011 27 PHP 5.4, essai PHPUnit Lançons la suite de tests de Symfony2 Symfony2 master PHPUnit 3.6.3
  • 28. PHP5.4 | PHPTour Lille 2011 28 PHP 5.4 – sort open tags <?= est toujours disponible quel que soit le niveau de sort_open_tags <?= $foo; ?>
  • 29. PHP5.4 | PHPTour Lille 2011 29 Serveur web embarqué Pas pour de la production ;-) Possibilité d'utiliser un routeur (script PHP) http://www.php.net/manual/fr/features.commandline.webserver.php
  • 30. PHP5.4 | PHPTour Lille 2011 30 Callable Nouveau typage : "callable" "callable" devient donc un mot reservé class PubSub { // code...... public function subscribe($name, callable $cb) { if (!isset($this->callbacks[$name])) { $this->callbacks[$name] = array(); } $this->callbacks[$name] = $cb; } } $ps = new PubSub(); $ps->subscribe('foo', function() { echo 'test'; }); $ps->subscribe('foo', 'bla'); // catchable fatal error
  • 31. PHP5.4 | PHPTour Lille 2011 31 Qu'est ce qui est "callable" ? Toute callback PHP : 'some-existing-function' array($someobj, 'some-public-method') array('someClass', 'some-static-public-method') function () { }; Notez cette nouvelle procédure d'invocation : class Hello { public function world($x) { return "hello $x"; } } $f = array(new Hello, 'world'); var_dump($f('foo')); // hello foo
  • 32. PHP5.4 | PHPTour Lille 2011 32 Short Array Syntax Python or Javascript anyone ? $cfg = array('loglevel' => 3, 'database' => array('username' => 'foo', 'password' => 'secret') ); $cfg = ['loglevel' => 3, 'database' => ['username' => 'foo', 'password' => 'secret'] ];
  • 33. PHP5.4 | PHPTour Lille 2011 33 Arrays dereferencing Oui, ça c'était très attendu ... function foo() { return array('foo'=>'bar'); } $var = foo()['foo'];
  • 34. PHP5.4 | PHPTour Lille 2011 34 "new" fluent interface On aime, on n'aime pas, on aime peut-être ... $obj = (new MyClass)->someMethod();
  • 35. PHP5.4 | PHPTour Lille 2011 35 Invocations statiques dynamiques echo Bar::{'foo'}();
  • 36. PHP5.4 | PHPTour Lille 2011 36 WTF ? OMG ! I love that (I really do) class Foo { public static function bar() { return ['wtf']; } public function wtf() { return 'omg'; } } $meth = 'bar'; var_dump( (new Foo)->{Foo::$meth()[0]}() ); // omg
  • 37. PHP5.4 | PHPTour Lille 2011 37 Notation binaire pour les entiers C'est vrai que ça manquait ;-) 0b var_dump( 0b1010 + (0b01<<2) ); // 14 http://julien-pauli.developpez.com/tutoriels/php/bool-op/
  • 38. PHP5.4 | PHPTour Lille 2011 38 Traits Mixins, héritage horizontal, héritage multiple Appelez-les comme vous voulez Aimez-les, ou pas … http://www.php.net/traits trait ToArray { public function toArray() { return $this->array; } }
  • 39. PHP5.4 | PHPTour Lille 2011 39 Traits trait ToArray { public function toArray() { return $this->array; } } class MainConfig { class Config extends MainConfig { private $array = ['foo']; use ToArray; public function config() { } private $array = ['bar']; } } $config = new Config; echo $config->toArray()[0]; // bar
  • 40. PHP5.4 | PHPTour Lille 2011 40 Closures Les closures supportent (enfin) $this Byebye $that et autres $self class A { private $value = 1; function firstGetter($name) { return function() use ($name) { $a = new A(); return $this->$name; $firstGetter = $a->firstGetter('value'); }; echo $firstGetter(); // 1 } $secondGetter = $a->secondGetter(); function secondGetter($name) { echo $secondGetter('value'); //1 return function($name) { return $this->$name; }; } }
  • 41. PHP5.4 | PHPTour Lille 2011 41 Domaine des closures Suite au support de $this, les closures peuvent maintenant changer de domaine class A { $a = new A; private $value = 1; $b = new B; function getter() { $closureA = $a->getter(); return function() { echo $closureA(); // 2 return ++$this->value;}; } $closureB = $closureA->bindTo($b, $b); } echo $closureB(); // 43 class B extends A { private $value = 42; }
  • 42. PHP5.4 | PHPTour Lille 2011 42 JSONSerializable Nouvelle interface Fonctionnement "à la __toString()" class Foo implements JsonSerializable { private $name = 'PHP'; public function jsonSerialize() { return "I love $this->name"; } } echo json_encode(new Foo);
  • 43. PHP5.4 | PHPTour Lille 2011 43 PHP a besoin de vous !
  • 44. PHP5.4 | PHPTour Lille 2011 44 Aidez-nous à tester PHP Compilez, make test, et envoyez vos résultats Lancez vos suites de tests sous PHP 5.4 Et faites nous suivre vos remarques Participez à l'élaboration de la documentation http://edit.php.net Présentation demain 11h45, salle 2, Yannick Torres
  • 45. PHP5.4 | PHPTour Lille 2011 45 Aidez-nous à tester PHP Compilez, make test, et envoyez vos résultats http://qa.php.net/reports/?version=5.4.0RC1 http://gcov.php.net/viewer.php?version=PHP_5_4 Lancez vos suites de tests sous PHP 5.4 Et faites nous suivre vos remarques Participez à l'élaboration de la documentation http://edit.php.net Présentation demain 11h45, salle 2, Yannick Torres
  • 46. PHP5.4 | PHPTour Lille 2011 46 Ressources, infos PHP 5.4 : 2011 Décembre ? Cadeau de Noël ? On est en RC2 pour le moment http://www.php.net/manual/fr/migration54.php En cours d’élaboration https://wiki.php.net/todo/php54 Toutes les RFC en cours : https://wiki.php.net/rfc
  • 47. PHP5.4 | PHPTour Lille 2011 47 Merci ! Merci à la communauté PHP Merci à ses contributeurs Felipe Pena, Etienne Kneuss, Stanislav Malyshev, Gustavo André dos Santos Lopes, David Soria Parra, Christian Stocker, Rob Richards, Pierre Joye, Zeev Suraski, Ilia Alshanetsky […] Merci à vous ! Nous recrutons :) Passez me voir
  • 48. PHP5.4 | PHPTour Lille 2011 48 Questions ? Chattez avec David Soria Parra De 12h30 à 14h IRC Freenode #phptour http://webchat.freenode.net