SlideShare a Scribd company logo
1 of 64
Construire des applications web performantes et élégantes avec Symfony2 @hhamon - WebEvent  La Ferme du Web – Lyon – 7 mai 2011
R&D Audit & Conseil Media Formation & Coaching Développement
Composants indépendants et découplés du framework…
Framework « full-stack »
Bundles Métiers Bundles Tiers Configuration Bundles Standards Core Bundles + Bridges Composants Bibliothèques
« Un Bundle est un répertoire qui contient une structure bien précise et qui héberge tous les fichiers d’une même fonctionnalité.  »
Un frameworksimple et unique !
Respectueux des standards et bonnes pratiques ,[object Object]
PHPUnit
Jinja Templates
Spring Security
Design Patterns,[object Object]
Distributions disponibles Télécharger l’Edition Standardqui héberge le framework, les bibliothèques tierces et les bundles standards
Configuration simplifiée
Configuration de la base de données.
Démarrage immédiat avec Symfony2. Happy coding
Envie de l’essayer ?
La philosophie de Symfony2 « Convertir une Requête entrante en une Réponse »
Générer une réponse brute classDefaultControllerextends Controller { /** @Route("/hello/{name}") */ public functionindexAction($name)     { // ... do things with $name returnnewResponse('Hello '. $name);     } }
Générer un template classDefaultControllerextends Controller { /** @Route("/hello/{name}") */ public functionindexAction($name)     { // ... do things with $name return $this->render( 'AcmeHelloBundle:Default:index.html.twig', array('name'=> $name)        );     } }
Puissance des annotations classDefaultControllerextends Controller { /**      * @Route("/schedule") * @Template      */ public functionindexAction()     {         $title='WebEvent 2011 Schedule'; returnarray('title'=> $title);     } }
Templating avec Twig {%extends"ConfooConferenceBundle::layout.html.twig"%} {%blockcontent%}     <h1> {{title}} </h1>     <ul>         <li>Caching on the Edge, by Fabien Potencier</li>         <li>HipHop for PHP, by Scott Mac Vicar</li>         <li>XDebug, by Derick Rethans</li>         <li>...</li>     </ul> {%endblock%}
Le moteur de templateTwig Twig est un moteur de templatingmoderne ,[object Object]
Syntaxe concise et riche
Echappement automatique
Fonctionnalités modernes
Extensible
Flexible,[object Object]
Héritage de template {%extends"::base.html.twig"%} {%blockbody%}     <imgsrc="/images/logo.gif" alt="Confoo 2011"/> {%blockcontent%}{%endblock%} {%endblock%} layout.html.twig
Héritage de templates <!DOCTYPE html> <html>     <head>         <meta http-equiv="Content-Type"             content="text/html; charset=utf-8" />         <title>{%blocktitle%}Welcome!{%endblock%}</title>         <link rel="shortcut icon" href="{{asset('favicon.ico') }}" />     </head>     <body> {%blockbody%}{%endblock%}     </body> </html> base.html.twig
Héritage de template base.html.twig layout.html.twig index.html.twig
Simplifier la définition des URLs
URLs propres Les URLs classiques ça craint !!!
URLs propres Système de routage natif
URL propres classDefaultControllerextends Controller { /** * @Route("/{year}/talk/{month}/{day}/{slug}")      * @Template      */ public functionshowAction($slug, $day, $month, $year)     { // Get a talk objectfrom the database $talk =...; returnarray('talk'=> $talk);     } }
Conversion automatique des paramètres classDefaultControllerextends Controller { /** * @Route("/talk/{id}")      * @Template      */ public functionshowAction(Talk $talk) { returnarray('talk'=> $talk);     } }
Simplifier le Débogage
La barre de débogage Memory Queries Recorded logs Timers Currentenvironment Currentresponse Symfony2 version PHP environment
Les traces d’exception
Traces d’exception
Journalisation interne
L’application Profiler
L’application Profiler
Simplifier les interactions  avec la BDD
Bibliothèque Doctrine 2 ,[object Object]
Mapping Objet Relationnel (ORM)
Support des Migrations
Mapping Objet Document (ODM - MongoDB)
Mapping Objet XML (OXM -XML databases),[object Object]
Persistance des entités en BDD classTalkControllerextends Controller { /** @Route("/talks/new") */ public functioncreateAction()     {         $em= $this->get('registry')->getEntityManager();         $talk =newTalk();         $talk->setTitle('Symfony2, a professional framework');         $talk->setSchedule(new ateTime('2011-03-12 16:00'));         $talk->addSpeaker(newSpeaker('Hugo Hamon'));         $talk->addSpeaker(newSpeaker('Fabien Potencier'));         $em->persist($talk);         $em->flush();     } }
Simplifier la validation des données
Validation ,[object Object]
Annotations
Extensible
Formulaires,[object Object]
Simplifier  la gestion des formulaires
Traitement des formulaires ,[object Object]
Protection CSRF
Validation
Templating avec Twig,[object Object]
Traitement du formulaire public functionindexAction() {     $product =newProduct();     $form =...;     $request = $this->get('request'); if ('POST' === $request->getMethod()) {         $form->bindRequest($request); if ($form->isValid()) { // handle data, persist the object to the database...         }     } returnarray('form'=> $form->createView()); }
Prototypage avec Twig <form action="#" method="post"> {{form_widget(form)}}     <button type="submit">     Create the product    </button> </form>
Fonctions de rendu avec Twig

More Related Content

What's hot

jQuery — fonctionnalités avancées
jQuery — fonctionnalités avancéesjQuery — fonctionnalités avancées
jQuery — fonctionnalités avancées
Rémi Prévost
 
Communications Réseaux et HTTP avec PHP
Communications Réseaux et HTTP avec PHPCommunications Réseaux et HTTP avec PHP
Communications Réseaux et HTTP avec PHP
julien pauli
 
PHP5 - POO
PHP5 - POOPHP5 - POO
PHP5 - POO
mazenovi
 

What's hot (20)

Modèle de domaine riche dans une application métier complexe un exemple pratique
Modèle de domaine riche dans une application métier complexe un exemple pratiqueModèle de domaine riche dans une application métier complexe un exemple pratique
Modèle de domaine riche dans une application métier complexe un exemple pratique
 
Notions de base de JavaScript
Notions de base de JavaScriptNotions de base de JavaScript
Notions de base de JavaScript
 
Formulaires Symfony2 - Cas pratiques et explications
Formulaires Symfony2 - Cas pratiques et explicationsFormulaires Symfony2 - Cas pratiques et explications
Formulaires Symfony2 - Cas pratiques et explications
 
Playing With PHP 5.3
Playing With PHP 5.3Playing With PHP 5.3
Playing With PHP 5.3
 
ZendFramework2 - Présentation
ZendFramework2 - PrésentationZendFramework2 - Présentation
ZendFramework2 - Présentation
 
Cours php & Mysql - 4éme partie
Cours php & Mysql - 4éme partieCours php & Mysql - 4éme partie
Cours php & Mysql - 4éme partie
 
Cours php
Cours phpCours php
Cours php
 
Cours php
Cours phpCours php
Cours php
 
Programmation Orientée Objet et les Traits en PHP 5.4
Programmation Orientée Objet et les Traits en PHP 5.4Programmation Orientée Objet et les Traits en PHP 5.4
Programmation Orientée Objet et les Traits en PHP 5.4
 
Formation PHP
Formation PHPFormation PHP
Formation PHP
 
jQuery — fonctionnalités avancées
jQuery — fonctionnalités avancéesjQuery — fonctionnalités avancées
jQuery — fonctionnalités avancées
 
Cours php & Mysql - 2éme partie
Cours php & Mysql - 2éme partieCours php & Mysql - 2éme partie
Cours php & Mysql - 2éme partie
 
SOLID : les principes à l’origine du succès de Symfony et de vos applications
SOLID : les principes à l’origine du succès de Symfony et de vos applicationsSOLID : les principes à l’origine du succès de Symfony et de vos applications
SOLID : les principes à l’origine du succès de Symfony et de vos applications
 
Les structures de données PHP5
Les structures de données PHP5Les structures de données PHP5
Les structures de données PHP5
 
Symfony CQRS and _event_sourcing
Symfony CQRS and _event_sourcingSymfony CQRS and _event_sourcing
Symfony CQRS and _event_sourcing
 
Javascript et JQuery
Javascript et JQueryJavascript et JQuery
Javascript et JQuery
 
Communications Réseaux et HTTP avec PHP
Communications Réseaux et HTTP avec PHPCommunications Réseaux et HTTP avec PHP
Communications Réseaux et HTTP avec PHP
 
SQL et MySQL
SQL et MySQLSQL et MySQL
SQL et MySQL
 
La première partie de la présentation PHP
La première partie de la présentation PHPLa première partie de la présentation PHP
La première partie de la présentation PHP
 
PHP5 - POO
PHP5 - POOPHP5 - POO
PHP5 - POO
 

Viewers also liked

Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
Hugo Hamon
 
Designing for developers
Designing for developersDesigning for developers
Designing for developers
Kirsten Hunter
 

Viewers also liked (20)

Monitor the quality of your Symfony projects
Monitor the quality of your Symfony projectsMonitor the quality of your Symfony projects
Monitor the quality of your Symfony projects
 
Facebook appsincloud
Facebook appsincloudFacebook appsincloud
Facebook appsincloud
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Api 101
Api 101Api 101
Api 101
 
API First
API FirstAPI First
API First
 
Prototyping in the cloud
Prototyping in the cloudPrototyping in the cloud
Prototyping in the cloud
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
 
Symfony2 en pièces détachées
Symfony2 en pièces détachéesSymfony2 en pièces détachées
Symfony2 en pièces détachées
 
Liberating your data
Liberating your dataLiberating your data
Liberating your data
 
Liberating your data
Liberating your dataLiberating your data
Liberating your data
 
Designing for developers
Designing for developersDesigning for developers
Designing for developers
 
This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?
This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?
This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?
 
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleDesign Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et Pimple
 
Quantifying fitness
Quantifying fitnessQuantifying fitness
Quantifying fitness
 
Développeurs, cachez-moi ça ! (Paris Web 2011)
Développeurs, cachez-moi ça ! (Paris Web 2011)Développeurs, cachez-moi ça ! (Paris Web 2011)
Développeurs, cachez-moi ça ! (Paris Web 2011)
 
API 101 Workshop from APIStrat Conference
API 101 Workshop from APIStrat ConferenceAPI 101 Workshop from APIStrat Conference
API 101 Workshop from APIStrat Conference
 
Symfony2 - extending the console component
Symfony2 - extending the console componentSymfony2 - extending the console component
Symfony2 - extending the console component
 
Polyglot copy
Polyglot copyPolyglot copy
Polyglot copy
 
Git store
Git storeGit store
Git store
 
Api intensive - What they Are
Api intensive - What they AreApi intensive - What they Are
Api intensive - What they Are
 

Similar to Symfony2 - Un Framework PHP 5 Performant

Presentation Spring, Spring MVC
Presentation Spring, Spring MVCPresentation Spring, Spring MVC
Presentation Spring, Spring MVC
Nathaniel Richand
 
Rich Desktop Applications
Rich Desktop ApplicationsRich Desktop Applications
Rich Desktop Applications
goldoraf
 
Soutenance Zend Framework vs Symfony
Soutenance Zend Framework vs SymfonySoutenance Zend Framework vs Symfony
Soutenance Zend Framework vs Symfony
Vincent Composieux
 

Similar to Symfony2 - Un Framework PHP 5 Performant (20)

iTunes Stats
iTunes StatsiTunes Stats
iTunes Stats
 
HTML5
HTML5HTML5
HTML5
 
Linq et Entity framework
Linq et Entity frameworkLinq et Entity framework
Linq et Entity framework
 
Presentation Spring, Spring MVC
Presentation Spring, Spring MVCPresentation Spring, Spring MVC
Presentation Spring, Spring MVC
 
Tapestry
TapestryTapestry
Tapestry
 
Jump Camp - HTML5
Jump Camp - HTML5Jump Camp - HTML5
Jump Camp - HTML5
 
ASP.NET MVC, Web API & KnockoutJS
ASP.NET MVC, Web API & KnockoutJSASP.NET MVC, Web API & KnockoutJS
ASP.NET MVC, Web API & KnockoutJS
 
Atelier template
Atelier templateAtelier template
Atelier template
 
Utilisation de ZK avec Java - Retour d’expérience
Utilisation de ZK avec Java - Retour d’expérienceUtilisation de ZK avec Java - Retour d’expérience
Utilisation de ZK avec Java - Retour d’expérience
 
Rich Desktop Applications
Rich Desktop ApplicationsRich Desktop Applications
Rich Desktop Applications
 
Association 2 0
Association 2 0Association 2 0
Association 2 0
 
Association 2 0
Association 2 0Association 2 0
Association 2 0
 
Introduction aux Web components (DNG Consulting)
Introduction aux Web components (DNG Consulting)Introduction aux Web components (DNG Consulting)
Introduction aux Web components (DNG Consulting)
 
Spring 3.0
Spring 3.0Spring 3.0
Spring 3.0
 
La mobilité dans Drupal
La mobilité dans DrupalLa mobilité dans Drupal
La mobilité dans Drupal
 
HTML5 en projet
HTML5 en projetHTML5 en projet
HTML5 en projet
 
Soutenance Zend Framework vs Symfony
Soutenance Zend Framework vs SymfonySoutenance Zend Framework vs Symfony
Soutenance Zend Framework vs Symfony
 
Présentation de Django @ Orange Labs (FR)
Présentation de Django @ Orange Labs (FR)Présentation de Django @ Orange Labs (FR)
Présentation de Django @ Orange Labs (FR)
 
Présentation WPF
Présentation  WPFPrésentation  WPF
Présentation WPF
 
Quoi de neuf dans Zend Framework 1.10 ?
Quoi de neuf dans Zend Framework 1.10 ?Quoi de neuf dans Zend Framework 1.10 ?
Quoi de neuf dans Zend Framework 1.10 ?
 

More from Hugo Hamon

Intégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec JenkinsIntégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec Jenkins
Hugo Hamon
 
Exposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
Exposer des services web SOAP et REST avec symfony 1.4 et Zend FrameworkExposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
Exposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
Hugo Hamon
 

More from Hugo Hamon (8)

Database Design Patterns
Database Design PatternsDatabase Design Patterns
Database Design Patterns
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
 
Intégration Continue PHP avec Jenkins CI
Intégration Continue PHP avec Jenkins CIIntégration Continue PHP avec Jenkins CI
Intégration Continue PHP avec Jenkins CI
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
Intégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec JenkinsIntégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec Jenkins
 
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
 
Introduction à Symfony2
Introduction à Symfony2Introduction à Symfony2
Introduction à Symfony2
 
Exposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
Exposer des services web SOAP et REST avec symfony 1.4 et Zend FrameworkExposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
Exposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
 

Symfony2 - Un Framework PHP 5 Performant