SlideShare une entreprise Scribd logo
symfony
                         Simplifier le développement des
                           interfaces bases de données

                                         Fabien Potencier
                                http://www.symfony-project.com/
                                   http://www.sensiolabs.com/



Forum PHP - Paris 2007      www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Sensio Labs | Fabien Potencier
  • Sensio
                                                                                                    Sensio
          –   Agence Interactive                                                               Agence Interactive

          –   Créée en 1998                                                         Webmarketing
                                                                                                              Technologies
                                                                                                                Internet
          –   Groupe de 150 personnes
          –   30 personnes dédiées à Internet


  • Spécialiste du monde Open-Source                                                        Créateur
          – Un pôle R&D dédié à l’Open-Source                                          Framework symfony


  • Des clients Grands Comptes et Institutionnels


Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
symfony
  • Framework Web PHP 5
  • Basé sur
          – 9 ans d’expérience Sensio
          – des projets Open-Source existants
  • Open-Source
  • Conçu pour gérer :
          – Sites professionnels
          – Problématiques complexes                                                            Licence MIT

          – Environnements exigeants

Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Les Buts de symfony
  • Rapprocher le monde de l’Entreprise
    et le monde de l’Open-Source

  • Développer plus vite

  • Ne pas réinventer la roue




Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Développer plus vite
  • Une ligne de code a un coût
                                                                                    moins de code
          – Pour l’écrire                                                                  
          – Pour la tester                                                        moins de complexité
          – Pour la maintenir                                                              
                                                                                    moins de bugs
  • Ecrire moins de code                                                                   
                                                                                  gain de productivité
          –   Architecture : contrôleur, ORM, …                                            
          –   Fichiers de configuration                                              gain de temps
          –   Autoloading
          –   Générateurs
          –   Helpers
  • Plus de temps pour les règles métiers, cas limites, …
Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Ne pas réinventer la roue
  • Intégrer les Bonnes Pratiques
  • Architecture MVC : Modèle / Vue / Contrôleur

  • Tests unitaires et fonctionnels
  •     Gestion des déploiements, support des environnements
  •     Configurabilité
  •     Sécurité (protection XSS et CSRF par défaut)
  •     Extensibilité (système de plugins)
  •     Admin Generator                               simplifier
                                                                                                        la vie


Forum PHP - Paris 2007     www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Les Principaux Atouts
  • symfony, c’est du code efficace
    mais c’est également…
  • Documentation
          – Un livre sous licence GFDL (450p)
          – Le tutorial askeet (250p)
  • 1.0 maintainue par Sensio
          – ~1 mise à jour par mois (bugs)
          – Support Commercial                                                                        1.0
          – Formations


Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Interfaces Bases de Données
  • Des besoins différents selon la cible
          – Pour l’administrateur
          – Pour le développeur
          – Pour le client
  • Des moteurs différents
          –   MySQL
          –   PostgreSQL
          –   Oracle
          –   MS SQL
          –   DB2
          –   …


Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Pour l’Administrateur
  • La ligne de commande
  • Interfaces visuelles Desktop ou Web
          – phpMyAdmin / MySQL Administrator
          – phpPgAdmin / pgAdmin




Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Pour le Développeur
  • Couche d’abstraction Base de données
          – Creole
          – PDO (PHP 5.1)
  • ORM Tools (Object Relational Mapping)
          – Propel
          – Doctrine
  • Générateurs dans symfony



Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Pour le Client
  • Front-Office :
          – Interaction en lecture principalement
          – Formulaires


  • Back-Office
          – Listes, filtres, pagination
          – CRUD : Create Read Update Delete




Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Abstraction SQL
  • Creole permet d’abstraire les différences SQL
          – Gestion des limit / offset
          – Gestion des dates
          –…




Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Le Modèle (Propel)
  // lib/model/Author.php
  class Author extends BaseAuthor
  {
    function getFullName()
    {
      return $this->getFirstName().' '.$this->getLastName();
    }
  }

  $author = new Author();
  $author->setFirstName('Fabien');
  $author->setLastName('Potencier');
  $author->save();

  $post = new Post();
  $post->setAuthor($author);
  $post->setPublishedOn('tomorrow 12:00');
  $post->isPublished(true);
  $post->save();

  $posts = PostPeer::doSelect(new Criteria());



Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Le Modèle (Doctrine)
  // lib/model/doctrine/lib/Author.php
  class Author extends BaseAuthor
  {
    function getFullName()
    {
      return $this->getFirstName().' '.$this->getLastName();
    }
  }

  $author = new Author();
  $author->setFirstName('Fabien');
  $author->setLastName('Potencier');
                                                                      Même mode de fonctionnement que Propel
  $author->save();

  $post = new Post();
  $post->setAuthor($author);
  $post->setPublishedOn('tomorrow 12:00');
  $post->isPublished(true);
  $post->save();




  $posts = Doctrine::getTable('Post')->findAll();

  $post = Doctrine::getTable('Post')->find($request->getParameter('id'));




Forum PHP - Paris 2007                 www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Création du Back-Office
  • Création automatique d’une Console
    d’Administration de Production
          – Listes                     – Filtres                                          Code généré MVC
                                                                                          et personnalisable
          – Pagination                 – Validation                                      Fichier configuration
                                                                                              Contrôleur
          – Tri                        – CRUD                                                 Templates


  $ ./symfony propel-init-admin frontend post Post



                                                                                    1) Crée un module post
                                                                                    2) Génère la configuration


Forum PHP - Paris 2007    www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Admin Generator
  • Liste




Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Admin Generator
  • Edition




   __toString()


                                                         widgets                                      m2m relationship


Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Extensibilité
  • Extension du module
         class postActions extends autoPostActions
         {
           protected function addFiltersCriteria($c)                                                     Generated
           {                                                                                              module
             $c->add(PostPeer::IS_PUBLISHED, true);
             parent::addFiltersCriteria($c);
           }
         }

  • Personnalisation des templates
              _edit_* : actions, footer, form, header, messages
              _list_* : footer, header, messages, td_actions, t(d|h)_stacked, t(d|h)_tabular
              _filters, editSuccess, listSuccess

Forum PHP - Paris 2007      www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Configurabilité

           # apps/frontend/modules/post/config/generator.yml
           generator:
              class:         sfPropelAdminGenerator
              param:
                model_class: Post
            list:
              display: [=title, author, created_on]
              filters: [title, author, published_on]




Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Démonstration




Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Les Formulaires
  • Peu de valeur ajoutée du développeur…
  • ... mais sujet complexe
          – Validation
          – Affichage
          – Sérialisation en base de données
          – Séparation entre les 3 couches MVC




Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Les Formulaires dans symfony 1.1
  • 3 niveaux
          – sfValidator : gestion de la validation
          – sfWidget : gestion des widgets HTML
          – sfForm : gestion du cycle de vie d’un formulaire




Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
sfFormPropel
  • Formulaire générées pour les objets Propel
  • Entièrement personnalisables
  • Introspection du schéma :
          – Converti le type Propel/Creole en validateurs et
            widgets symfony
          – Clés étrangères
          – Relations n / n
          – Gestion des tables d’internationalisation



Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
sfFormPropel
  class bookActions        extends sfActions
  {
    public function        executeEdit($request)
    {
      $this->book =        BookPeer::retrieveByPk($request->getParameter('id'));
      $this->form =        new AuthorForm($this->book);

          if ($request->isMethod('post'))
          {
            $this->form->bind($request->getParameter('book');
            if ($this->form->isValid())
            {
              $book = $this->form->save();

                  $this->redirect('@book?id='.$book->getId());
              }
          }
      }
  }


Forum PHP - Paris 2007      www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Personnaliser les Forms Propel
  class BookForm extends BaseBookForm
  {
    public function configure()
    {
      $this->embedI18n(array('en', 'fr'));

          $this->widgetSchema['en']->setLabel('en', 'English');

          unset($this['created_at']);

          $this->validatorSchema['foo'] = new sfValidatorPass();
          $this->widgetSchema['foo'] = new sfWidgetIdentity();

          $this->setDefault('published_on', time());
      }
  }



Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Un Framework pour les Professionnels
  •     Issue de l’expérience
  •     1.0 stable, maintenue et support commercial
  •     Communauté large et compétente
  •     Extensibilité
  •     Stabilité de l’API
  •     Documentation
                                                                                          Une vision du Web
                                                                                           Professionnelle
                                                                                            Pragmatique


Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Quelques Chiffres
  •     3 ans de R&D
  •     Version 1.0 stable
  •     Support commercial
  •     Documentation Open-Source
          – Livre référence (450 pages - GFDL)
          – Tutorial pas à pas (250 pages)
  • Communauté importante
                                                                                               Mature
          – Développeurs dans 80 pays                                                         Reconnu
          – 300 000 visiteurs par mois
Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Next symfony Workshops


   En français : Paris, France - Dec 05, 2007

      In English : Paris, France - Feb 13, 2008

            Plus d’informations sur www.sensiolabs.com


Forum PHP - Paris 2007     www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Rejoignez-nous
  • Sensio Labs recrute en France
          – Des développeurs
          – Des chefs de projet technique
  • Le Web est l’une de vos passions ?
          – Développeur : Vous avez une expérience dans le
            développement de sites Web en PHP voire en
            symfony. Vous développez en PHP5 objets, vous
            connaissez l’AJAX.
          – Chef de Projet : Vous êtes développeur et vous
            souhaitez gérer des projets pour des grands comptes.

Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com
Sensio S.A.
                                     26, rue Salomon de Rothschild
                                         92 286 Suresnes cedex
                                                 France
                                            Tél. : +33 1 40 99 80 80
                                            Fax : +33 1 40 99 83 34

                                                 Contact
                                            Fabien Potencier
                                      fabien.potencier@sensio.com




        http://www.sensiolabs.com/                                  http://www.symfony-project.com/
Forum PHP - Paris 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensiolabs.com

Contenu connexe

Tendances

Tendances (9)

Formation Symfony2 par KNP Labs
Formation Symfony2 par KNP LabsFormation Symfony2 par KNP Labs
Formation Symfony2 par KNP Labs
 
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
 
Symfony3 overview
Symfony3 overviewSymfony3 overview
Symfony3 overview
 
Formation PHP avancé - Cake PHP
Formation PHP avancé - Cake PHPFormation PHP avancé - Cake PHP
Formation PHP avancé - Cake PHP
 
Présentation symfony epita
Présentation symfony epitaPrésentation symfony epita
Présentation symfony epita
 
Conference Php Web Services
Conference Php Web ServicesConference Php Web Services
Conference Php Web Services
 
Symfony 2 : chapitre 1 - Présentation Générale
Symfony 2 : chapitre 1 - Présentation GénéraleSymfony 2 : chapitre 1 - Présentation Générale
Symfony 2 : chapitre 1 - Présentation Générale
 
Alphorm.com Formation OpenVZ
Alphorm.com Formation OpenVZAlphorm.com Formation OpenVZ
Alphorm.com Formation OpenVZ
 
Outillage pour Windows 8 XAML
Outillage pour Windows 8 XAMLOutillage pour Windows 8 XAML
Outillage pour Windows 8 XAML
 

Similaire à symfony : Simplifier le développement des interfaces bases de données (PHP Forum 2007)

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
 
Conférence #nwx2014 - Maxime Mauchaussée - Partager du code maintenable et év...
Conférence #nwx2014 - Maxime Mauchaussée - Partager du code maintenable et év...Conférence #nwx2014 - Maxime Mauchaussée - Partager du code maintenable et év...
Conférence #nwx2014 - Maxime Mauchaussée - Partager du code maintenable et év...
Normandie Web Xperts
 
Je configure mes serveurs avec fabric et fabtools
Je configure mes serveurs avec fabric et fabtoolsJe configure mes serveurs avec fabric et fabtools
Je configure mes serveurs avec fabric et fabtools
Ronan Amicel
 

Similaire à symfony : Simplifier le développement des interfaces bases de données (PHP Forum 2007) (20)

Utilisation optimale et professionnelle de PHP
Utilisation optimale et professionnelle de PHPUtilisation optimale et professionnelle de PHP
Utilisation optimale et professionnelle de PHP
 
Presentation symfony
Presentation symfonyPresentation symfony
Presentation symfony
 
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
 
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
 
Déboguer une application web avec FirePHP
Déboguer une application web avec FirePHPDéboguer une application web avec FirePHP
Déboguer une application web avec FirePHP
 
Deboguer Avec Firephp
Deboguer Avec FirephpDeboguer Avec Firephp
Deboguer Avec Firephp
 
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
 
Symfony à la télé
Symfony à la téléSymfony à la télé
Symfony à la télé
 
Présentation de CakePHP, 22/04/2010
Présentation de CakePHP, 22/04/2010Présentation de CakePHP, 22/04/2010
Présentation de CakePHP, 22/04/2010
 
Orchestrez vos projets Symfony sans fausses notes
Orchestrez vos projets Symfony sans fausses notesOrchestrez vos projets Symfony sans fausses notes
Orchestrez vos projets Symfony sans fausses notes
 
Suivi qualité avec sonar pour php
Suivi qualité avec sonar pour phpSuivi qualité avec sonar pour php
Suivi qualité avec sonar pour php
 
Présentation welcom la webperf by object23
Présentation welcom la webperf by object23Présentation welcom la webperf by object23
Présentation welcom la webperf by object23
 
Conférence #nwx2014 - Maxime Mauchaussée - Partager du code maintenable et év...
Conférence #nwx2014 - Maxime Mauchaussée - Partager du code maintenable et év...Conférence #nwx2014 - Maxime Mauchaussée - Partager du code maintenable et év...
Conférence #nwx2014 - Maxime Mauchaussée - Partager du code maintenable et év...
 
Je configure mes serveurs avec fabric et fabtools
Je configure mes serveurs avec fabric et fabtoolsJe configure mes serveurs avec fabric et fabtools
Je configure mes serveurs avec fabric et fabtools
 
sfPot aop
sfPot aopsfPot aop
sfPot aop
 
Gérer ses environnements de développement avec vagrant - PHP Tour Nantes 2012
Gérer ses environnements de développement avec vagrant - PHP Tour Nantes 2012Gérer ses environnements de développement avec vagrant - PHP Tour Nantes 2012
Gérer ses environnements de développement avec vagrant - PHP Tour Nantes 2012
 
Performance au quotidien dans un environnement symfony
Performance au quotidien dans un environnement symfonyPerformance au quotidien dans un environnement symfony
Performance au quotidien dans un environnement symfony
 
Mon environnement de travail a-t-il encore un avenir ?
Mon environnement de travail a-t-il encore un avenir ?Mon environnement de travail a-t-il encore un avenir ?
Mon environnement de travail a-t-il encore un avenir ?
 
Php dans le cloud
Php dans le cloudPhp dans le cloud
Php dans le cloud
 
PHP dans le cloud
PHP dans le cloudPHP dans le cloud
PHP dans le cloud
 

Plus de Fabien Potencier

Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4
Fabien Potencier
 
Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Dependency injection-zendcon-2010
Dependency injection-zendcon-2010
Fabien Potencier
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
Fabien Potencier
 
The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010
Fabien Potencier
 
Dependency injection - phpday 2010
Dependency injection - phpday 2010Dependency injection - phpday 2010
Dependency injection - phpday 2010
Fabien Potencier
 
Dependency Injection IPC 201
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201
Fabien Potencier
 
Caching on the Edge with Symfony2
Caching on the Edge with Symfony2Caching on the Edge with Symfony2
Caching on the Edge with Symfony2
Fabien Potencier
 
Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2
Fabien Potencier
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
Fabien Potencier
 
Dependency Injection - ConFoo 2010
Dependency Injection - ConFoo 2010Dependency Injection - ConFoo 2010
Dependency Injection - ConFoo 2010
Fabien Potencier
 

Plus de Fabien Potencier (20)

Varnish
VarnishVarnish
Varnish
 
Look beyond PHP
Look beyond PHPLook beyond PHP
Look beyond PHP
 
Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4
 
Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Dependency injection-zendcon-2010
Dependency injection-zendcon-2010
 
Caching on the Edge
Caching on the EdgeCaching on the Edge
Caching on the Edge
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
 
The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010
 
PhpBB meets Symfony2
PhpBB meets Symfony2PhpBB meets Symfony2
PhpBB meets Symfony2
 
Dependency injection - phpday 2010
Dependency injection - phpday 2010Dependency injection - phpday 2010
Dependency injection - phpday 2010
 
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
 
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
 
Symfony2 - OSIDays 2010
Symfony2 - OSIDays 2010Symfony2 - OSIDays 2010
Symfony2 - OSIDays 2010
 
Dependency Injection IPC 201
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201
 
Caching on the Edge with Symfony2
Caching on the Edge with Symfony2Caching on the Edge with Symfony2
Caching on the Edge with Symfony2
 
Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
 
Dependency Injection - ConFoo 2010
Dependency Injection - ConFoo 2010Dependency Injection - ConFoo 2010
Dependency Injection - ConFoo 2010
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Symfony Components
Symfony ComponentsSymfony Components
Symfony Components
 
PHP 5.3 in practice
PHP 5.3 in practicePHP 5.3 in practice
PHP 5.3 in practice
 

Dernier

Dernier (6)

Protéger l'intégrité de son environnement numérique
Protéger l'intégrité de son environnement numériqueProtéger l'intégrité de son environnement numérique
Protéger l'intégrité de son environnement numérique
 
Augmentez vos conversions en ligne : les techniques et outils qui marchent vr...
Augmentez vos conversions en ligne : les techniques et outils qui marchent vr...Augmentez vos conversions en ligne : les techniques et outils qui marchent vr...
Augmentez vos conversions en ligne : les techniques et outils qui marchent vr...
 
Modèles de contrôle d accès_ RBAC (Role Based Access Control).pdf
Modèles de contrôle d accès_ RBAC (Role Based Access Control).pdfModèles de contrôle d accès_ RBAC (Role Based Access Control).pdf
Modèles de contrôle d accès_ RBAC (Role Based Access Control).pdf
 
Slides du webinaire de l'Infopole sur l'IA
Slides du webinaire de l'Infopole sur l'IASlides du webinaire de l'Infopole sur l'IA
Slides du webinaire de l'Infopole sur l'IA
 
Contrôle d’accès et Gestion des identités: Terminologies et Protocoles d’auth...
Contrôle d’accès et Gestion des identités: Terminologies et Protocoles d’auth...Contrôle d’accès et Gestion des identités: Terminologies et Protocoles d’auth...
Contrôle d’accès et Gestion des identités: Terminologies et Protocoles d’auth...
 
cours Systèmes de Gestion des Identités.pdf
cours Systèmes de Gestion des Identités.pdfcours Systèmes de Gestion des Identités.pdf
cours Systèmes de Gestion des Identités.pdf
 

symfony : Simplifier le développement des interfaces bases de données (PHP Forum 2007)

  • 1. symfony Simplifier le développement des interfaces bases de données Fabien Potencier http://www.symfony-project.com/ http://www.sensiolabs.com/ Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 2. Sensio Labs | Fabien Potencier • Sensio Sensio – Agence Interactive Agence Interactive – Créée en 1998 Webmarketing Technologies Internet – Groupe de 150 personnes – 30 personnes dédiées à Internet • Spécialiste du monde Open-Source Créateur – Un pôle R&D dédié à l’Open-Source Framework symfony • Des clients Grands Comptes et Institutionnels Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 3. symfony • Framework Web PHP 5 • Basé sur – 9 ans d’expérience Sensio – des projets Open-Source existants • Open-Source • Conçu pour gérer : – Sites professionnels – Problématiques complexes Licence MIT – Environnements exigeants Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 4. Les Buts de symfony • Rapprocher le monde de l’Entreprise et le monde de l’Open-Source • Développer plus vite • Ne pas réinventer la roue Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 5. Développer plus vite • Une ligne de code a un coût moins de code – Pour l’écrire  – Pour la tester moins de complexité – Pour la maintenir  moins de bugs • Ecrire moins de code  gain de productivité – Architecture : contrôleur, ORM, …  – Fichiers de configuration gain de temps – Autoloading – Générateurs – Helpers • Plus de temps pour les règles métiers, cas limites, … Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 6. Ne pas réinventer la roue • Intégrer les Bonnes Pratiques • Architecture MVC : Modèle / Vue / Contrôleur • Tests unitaires et fonctionnels • Gestion des déploiements, support des environnements • Configurabilité • Sécurité (protection XSS et CSRF par défaut) • Extensibilité (système de plugins) • Admin Generator simplifier la vie Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 7. Les Principaux Atouts • symfony, c’est du code efficace mais c’est également… • Documentation – Un livre sous licence GFDL (450p) – Le tutorial askeet (250p) • 1.0 maintainue par Sensio – ~1 mise à jour par mois (bugs) – Support Commercial 1.0 – Formations Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 8. Interfaces Bases de Données • Des besoins différents selon la cible – Pour l’administrateur – Pour le développeur – Pour le client • Des moteurs différents – MySQL – PostgreSQL – Oracle – MS SQL – DB2 – … Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 9. Pour l’Administrateur • La ligne de commande • Interfaces visuelles Desktop ou Web – phpMyAdmin / MySQL Administrator – phpPgAdmin / pgAdmin Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 10. Pour le Développeur • Couche d’abstraction Base de données – Creole – PDO (PHP 5.1) • ORM Tools (Object Relational Mapping) – Propel – Doctrine • Générateurs dans symfony Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 11. Pour le Client • Front-Office : – Interaction en lecture principalement – Formulaires • Back-Office – Listes, filtres, pagination – CRUD : Create Read Update Delete Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 12. Abstraction SQL • Creole permet d’abstraire les différences SQL – Gestion des limit / offset – Gestion des dates –… Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 13. Le Modèle (Propel) // lib/model/Author.php class Author extends BaseAuthor { function getFullName() { return $this->getFirstName().' '.$this->getLastName(); } } $author = new Author(); $author->setFirstName('Fabien'); $author->setLastName('Potencier'); $author->save(); $post = new Post(); $post->setAuthor($author); $post->setPublishedOn('tomorrow 12:00'); $post->isPublished(true); $post->save(); $posts = PostPeer::doSelect(new Criteria()); Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 14. Le Modèle (Doctrine) // lib/model/doctrine/lib/Author.php class Author extends BaseAuthor { function getFullName() { return $this->getFirstName().' '.$this->getLastName(); } } $author = new Author(); $author->setFirstName('Fabien'); $author->setLastName('Potencier'); Même mode de fonctionnement que Propel $author->save(); $post = new Post(); $post->setAuthor($author); $post->setPublishedOn('tomorrow 12:00'); $post->isPublished(true); $post->save(); $posts = Doctrine::getTable('Post')->findAll(); $post = Doctrine::getTable('Post')->find($request->getParameter('id')); Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 15. Création du Back-Office • Création automatique d’une Console d’Administration de Production – Listes – Filtres Code généré MVC et personnalisable – Pagination – Validation Fichier configuration Contrôleur – Tri – CRUD Templates $ ./symfony propel-init-admin frontend post Post 1) Crée un module post 2) Génère la configuration Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 16. Admin Generator • Liste Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 17. Admin Generator • Edition __toString() widgets m2m relationship Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 18. Extensibilité • Extension du module class postActions extends autoPostActions { protected function addFiltersCriteria($c) Generated { module $c->add(PostPeer::IS_PUBLISHED, true); parent::addFiltersCriteria($c); } } • Personnalisation des templates _edit_* : actions, footer, form, header, messages _list_* : footer, header, messages, td_actions, t(d|h)_stacked, t(d|h)_tabular _filters, editSuccess, listSuccess Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 19. Configurabilité # apps/frontend/modules/post/config/generator.yml generator: class: sfPropelAdminGenerator param: model_class: Post list: display: [=title, author, created_on] filters: [title, author, published_on] Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 20. Démonstration Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 21. Les Formulaires • Peu de valeur ajoutée du développeur… • ... mais sujet complexe – Validation – Affichage – Sérialisation en base de données – Séparation entre les 3 couches MVC Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 22. Les Formulaires dans symfony 1.1 • 3 niveaux – sfValidator : gestion de la validation – sfWidget : gestion des widgets HTML – sfForm : gestion du cycle de vie d’un formulaire Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 23. sfFormPropel • Formulaire générées pour les objets Propel • Entièrement personnalisables • Introspection du schéma : – Converti le type Propel/Creole en validateurs et widgets symfony – Clés étrangères – Relations n / n – Gestion des tables d’internationalisation Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 24. sfFormPropel class bookActions extends sfActions { public function executeEdit($request) { $this->book = BookPeer::retrieveByPk($request->getParameter('id')); $this->form = new AuthorForm($this->book); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('book'); if ($this->form->isValid()) { $book = $this->form->save(); $this->redirect('@book?id='.$book->getId()); } } } } Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 25. Personnaliser les Forms Propel class BookForm extends BaseBookForm { public function configure() { $this->embedI18n(array('en', 'fr')); $this->widgetSchema['en']->setLabel('en', 'English'); unset($this['created_at']); $this->validatorSchema['foo'] = new sfValidatorPass(); $this->widgetSchema['foo'] = new sfWidgetIdentity(); $this->setDefault('published_on', time()); } } Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 26. Un Framework pour les Professionnels • Issue de l’expérience • 1.0 stable, maintenue et support commercial • Communauté large et compétente • Extensibilité • Stabilité de l’API • Documentation Une vision du Web Professionnelle Pragmatique Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 27. Quelques Chiffres • 3 ans de R&D • Version 1.0 stable • Support commercial • Documentation Open-Source – Livre référence (450 pages - GFDL) – Tutorial pas à pas (250 pages) • Communauté importante Mature – Développeurs dans 80 pays Reconnu – 300 000 visiteurs par mois Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 28. Next symfony Workshops En français : Paris, France - Dec 05, 2007 In English : Paris, France - Feb 13, 2008 Plus d’informations sur www.sensiolabs.com Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 29. Rejoignez-nous • Sensio Labs recrute en France – Des développeurs – Des chefs de projet technique • Le Web est l’une de vos passions ? – Développeur : Vous avez une expérience dans le développement de sites Web en PHP voire en symfony. Vous développez en PHP5 objets, vous connaissez l’AJAX. – Chef de Projet : Vous êtes développeur et vous souhaitez gérer des projets pour des grands comptes. Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com
  • 30. Sensio S.A. 26, rue Salomon de Rothschild 92 286 Suresnes cedex France Tél. : +33 1 40 99 80 80 Fax : +33 1 40 99 83 34 Contact Fabien Potencier fabien.potencier@sensio.com http://www.sensiolabs.com/ http://www.symfony-project.com/ Forum PHP - Paris 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensiolabs.com