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

Post on 08-Apr-2017

1.510 views 1 download

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

PHP : TROLLONS, MAIS TROLLONS BIEN!

QUI SUIS-JE ?Arnaud Langlade (@_aRn0D)

Développeur PHP/Symfony@CleverAge

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

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

Arnaud : PHP, mon polo!

Polo :

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() // ...

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

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

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) /*...*/

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();

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)

LA COMMUNAUTÉ EST LÀ ET ELLE...

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

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)

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

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...

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.

MERCI! QUESTIONS ?

Arnaud Langlade

Twiter @_aRn0D

Github @aRn0D