Php trollons-mais-trollons-bien (Bdx.io 2015)

16
PHP : TROLLONS, MAIS TROLLONS BIEN!

Transcript of Php trollons-mais-trollons-bien (Bdx.io 2015)

Page 1: Php trollons-mais-trollons-bien (Bdx.io 2015)

PHP : TROLLONS, MAIS TROLLONS BIEN!

Page 2: Php trollons-mais-trollons-bien (Bdx.io 2015)

QUI SUIS-JE ?Arnaud Langlade (@_aRn0D)

Développeur PHP/Symfony@CleverAge

Core team member @Sylius (et bientôt @akeneo)

Page 3: Php trollons-mais-trollons-bien (Bdx.io 2015)

POURQUOI CE TALK ?!?Polo : Quel langage, utilises tu ?

Arnaud : PHP, mon polo!

Polo :

Page 4: Php trollons-mais-trollons-bien (Bdx.io 2015)

OUI, EN PHP ON A VU ... (PHP4) require 'lib/function.php';

if (isset($_GET['page'])) echo "<html>"; include($_GET['page'].'.php'); echo "</html>";

class Connection var $dsn; function connection() // ...

Page 5: Php trollons-mais-trollons-bien (Bdx.io 2015)

On est d'accord, ça ne donne pas envie...

Page 6: Php trollons-mais-trollons-bien (Bdx.io 2015)

MAIS ÇA ÉVOLUE ! DEPUIS UN MOMENT DÉJÀ...

Page 7: Php trollons-mais-trollons-bien (Bdx.io 2015)

AMÉLIORATION DU MODE OBJET (PHP5) namespace Bdd/Common;

use Bdd/Common/Connection as BaseConnection;

class Connection extends BaseConnection implements ConnectionInterface, ContainerAwareInterface use ConnectionTrait;

const TYPE = 'my_sql';

private $dsn = null; // Peut être public ou protected

public function __construct(array $config) /*...*/

final public function query(Criteria $criteria) /*...*/

Page 8: Php trollons-mais-trollons-bien (Bdx.io 2015)

AMÉLIORATION DU MODE OBJET (PHP7) declare(strict_types = 1);

namespace Bdd/Common;

use Bdd/Common/Connection as BaseConnection;

class ConnectionFactory implements ConnectionFactoryInterface public function create(string $dsn) : Connection try return new Connection($dsn); catch (TypeError $e) // Une partie des erreurs Fatales sont transformées en Error echo $e­>getMessage();

Page 9: Php trollons-mais-trollons-bien (Bdx.io 2015)

LA DELOREAN EST EN MARCHE...Mélange procédural et d'objet (maisgros gap entre PHP4 et PHP7)L'api est très bien documentée (etinternationalisée)La core team a défini un processus derelease (RFC + Vote)Communauté vaste, expérimentée etorganisée (User group, conférence)

Page 10: Php trollons-mais-trollons-bien (Bdx.io 2015)

LA COMMUNAUTÉ EST LÀ ET ELLE...

Page 11: Php trollons-mais-trollons-bien (Bdx.io 2015)

LA COMMUNAUTÉLa communauté s'est bien diversifiée (il y'a de très bons développeurs)Les projets open source demandent une bonne qualité de code (design ettests)De nombreuse librairies sont disponibles ( )packagist.org

Page 12: Php trollons-mais-trollons-bien (Bdx.io 2015)

PHP FRAMEWORK INTEROP GROUP (PHPFIG)Regroupe des acteurs majeurs du monde PHP (Sf, Zf, eZ, Doctrine, etc.)Parle des problématiques communes à chaque projetCréation des PHP Standard Recommendation (PSRs)

Page 13: Php trollons-mais-trollons-bien (Bdx.io 2015)

LES NORMES PSR (PHP STANDARD RECOMMENDATION)PSR0 et PSR4 : Chargement des classesPSR1 et PSR2 : Style du codePSR3 : Gestion des logsPSR7 : Messages HTTP

Page 14: Php trollons-mais-trollons-bien (Bdx.io 2015)

INDUSTRIALISATION DE PHPGestionnaire de dépendences :Composer/^(|micro) framework$/: Symfony,Laravel, Zend, Yii, Slim, Silex, etc...Framework de tests : PhpUnit,Atoum, Behat ou bien PhpSpec.Intégration continue:PHP_CodeSniffer,PHP_Depend/PHPMD, PHPCPD,PhpDependencyAnalysis etc...

Page 15: Php trollons-mais-trollons-bien (Bdx.io 2015)

POUR FINIR

Ce n'est pas un langage quifait un développeur mais la

façon dont il l'utilise.

PHP et sa communautéévolue dans le bon sens mêmesi le langage n'est pas parfait.

Page 16: Php trollons-mais-trollons-bien (Bdx.io 2015)

MERCI! QUESTIONS ?

Arnaud Langlade

Twiter @_aRn0D

Github @aRn0D