SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
symfony
                  Simplify your professional
                  web development with PHP

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



PHP Quebec 2007   www.symfony-project.com    fabien.potencier@sensio.com   www.sensio.com
Sensio
  • French Web Agency, founded in 1998
         – 150 people
         – 30 people dedicated to Web technologies

                                                      SENSIO
                                                     Web Agency




                                                                        Web
                                      Webmarketing
                                                                    Technologies




                                                                     Open Source
                                                                    Technologies
                                                                  (Framework PHP)




PHP Quebec 2007   www.symfony-project.com    fabien.potencier@sensio.com      www.sensio.com
Sensio Labs
  • Open-Source technologies (LAMP stack)
         –   Linux
         –   Apache
         –   MySQL / PostgreSQL
         –   PHP / Perl / Python / Ruby
  • Open-Source dedicated team
  • Big company customers
         – Web Consulting                                                                 symfony
         – Audit / Training                                                            PHP Framework
         – Web Development


PHP Quebec 2007      www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
symfony
  •    PHP 5 Web Framework
  •    Based on 9 years of Sensio experience
  •    Based on well-known projets (Mojavi, Propel, Prado)
  •    Open-Source                                    Licence
  •    Built for :                                      MIT

         – Professional Websites
         – Complex needs
                                                                                   Bring together
         – Demanding environments                                                 Entreprise World
                                                                                 Open-Source World


PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Don’t reinvent the wheel
  • Follow best practices
  • MVC Pattern : Model / View / Controller

  • Unit and functional test framework
  • Environment and deployment support
  • Security (XSS protection by default)
  • Extensible (plugin system)
                                                                                            simplify
                                                                                            your life


PHP Quebec 2007    www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Develop faster
  • Each line of code has a cost
         – To write the line                                                           less code
                                                                                           
         – To test it
                                                                                    less complexity
         – To maintain it                                                                  
                                                                                       less bugs
  • Write less code                                                                        
         –   Architecture : controller, ORM, …                                     more productivity
                                                                                           
         –   Configuration
                                                                                       more time
         –   Autoloading
         –   Generators
         –   Helpers
  • More time for business rules, edge cases, …
PHP Quebec 2007      www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Main selling points
  •    Documentation
  •    Configurability
  •    XSS protection                                                                      Standard
  •    Debugging tools                                                                       PHP 5
                                                                                              MVC
  •    Functional tests                                                                     Routing
  •    Extensibility : Plugins                                                               Cache
  •    Admin Generator
  •    ORM : Propel or Doctrine
  •    i18n / l10n
  •    1.0 maintained for a long time
PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Symfony installation
  • PEAR
       $ pear channel-discover pear.symfony-project.com
       $ pear install symfony/symfony-1.0.0
                                                                                           PEAR package
                                                                                            Subversion
                                                             easy
                                                                                             Package
  • SVN / symlink                                                                            Sandbox
       $ svn propedit svn:externals
       symfony http://svn.symfony-project.com/branches/1.0

                                                                          recommended
  • Sandbox
       $ curl -O http://www.symfony-project.com/get/sf_sandbox-1.0.0.tgz
       $ tar zxpf sf_sandbox-1.0.0.tgz
                                                                                                     fast

PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Application Creation
  $ mkdir ~/sfdemo
  $ cd ~/sfdemo
                                                                                 Project
                                                                                  
  $ symfony init-project sfdemo                                               Application(s)
                                                                                  
  $ ./symfony init-app frontend
                                                                               Module(s)
                                                                                  
                                                                                Action(s)
                                                                              Composant(s)
                                                                                    
                                                                                Template




PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Database
  • Database configuration
         # config/databases.yml
         prod:                                                                                  Environment
           propel:
                                                                                                  support
             param:
               password: PAssWD
         all:
           propel:
             class:       sfPropelDatabase
             param:
               dsn:       mysql://root:@localhost/sfdemo

  • Schema definition                                                                          SQL abstraction
         # config/schema.yml
         post:
           title:        { type:        varchar, size: 255 }
           content:      { type:        longvarchar }
           is_published: { type:        boolean }
           author_id:    { type:        integer, foreignTable: author, foreignReference: id }
           created_at:   ~
PHP Quebec 2007      www.symfony-project.com    fabien.potencier@sensio.com   www.sensio.com
Database
  • Test data
           # data/fixtures/data.yml
           Author:
             fabien:
               first_name: Fabien
               last_name: Potencier
           Post:                                                            1) Creates model classes
             first_post:                                                    2) Converts schema to SQL
               author_id: fabien                                            3) Creates tables
               title:     PHP Québec                                        4) Loads test data


  $ ./symfony propel-build-all-load frontend



PHP Quebec 2007    www.symfony-project.com    fabien.potencier@sensio.com   www.sensio.com
Model
  // lib/model/Author.php
  class Author extends BaseAuthor
  {
    function getFullName()
    {
      return $this->getFirstName().' '.$this->getLastName();
    }
  }

  $author = new Author();
  $author->setFirstName('Fabien');                                                        ORM
  $author->setLastName('Potencier');                                          Object Relationship Mapping
  $author->save();
                                                                                   Propel / Doctrine
  $post = new Post();
  $post->setAuthor($author);
  $post->setPublishedOn('12:00 tomorrow');
  $post->isPublished(true);
  $post->save();

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



PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Backend creation
  • Automatic creation of an Administration Backend,
    ready for production
         – Lists                  – Filters                                      Generated code is MVC
                                                                                   and customizable
         – Pagination             – Validation                                        Configuration file
                                                                                         Controller
         – Tri                    – CRUD                                                 Templates


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



                                                                               1) Creates a post module
                                                                               2) Generates configuration


PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Configurability
  • Module level
         # apps/frontend/modules/post/config/generator.yml
         generator:
            class:         sfPropelAdminGenerator
            param:                                                                           Configuration
              model_class: Post                                                               Framework
              list:                                                                             Project
                display: [=title, author, created_at]
                                                                                              Application
                filters: [title, author_id, published_on]
                max_per_page: 5                                                                 Module

  • Application level
         # apps/frontend/config/security.yml
         default:
           is_secure:   on
           credentials: admin
                                                                                                    LOC : 0
  $ ./symfony plugin-install http://plugins.symfony-project.com/sfGuardPlugin

PHP Quebec 2007     www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Admin Generator
  • List




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




   __toString()


                                                      widgets                              m2m relationship


PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Extensibility
  • Module extension
         class postActions extends autoPostActions
         {
           protected function addFiltersCriteria($c)                                              Generated
           {                                                                                       module
             parent::addFiltersCriteria($c);
             $c->add(PostPeer::IS_PUBLISHED, true);
           }
         }

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

PHP Quebec 2007          www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Frontend Creation
  • Routing
                   homepage:
            /        param: { module: blog, action: recent }                 <?php echo url_for('@homepage') ?>
                     url:   /



                   homepage:
             /       param: { module: blog, action: list }
                     url:   /
                   recent:
        /recent      param: { module: blog, action: recent }
                     url:   /recent



                   post:
                                                                             <?php echo link_to(
                     param: { module: blog, action: show }
                                                                               $post->getTitle(),
  /blog/1.html       requirements:
                                                                               '@post?id=’.$post->getId()
                       id: d+
                                                                             ) ?>
                     url:   /blog/:id.html



PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Functional Tests
  • Navigation simulation
         // test/functional/frontend/blogActionsTest.php
         $browser = new sfTestBrowser();
         $browser->initialize();                                       TDD
         $browser->                                          Test Driven Development
           get('/blog/1.html')->
           isStatusCode(200)->
           checkResponseElement('h1.title', '/PHP Québec/');

  $ ./symfony test-functional frontend
                                                                    CSS Selector
  # get /
  ok 1 - status code is 200
  not ok 2 - response selector h1 does not match regex /PHP Québec/
  # Looks like you failed 1 tests of 2
  1..2



PHP Quebec 2007      www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Our first line of code
  # apps/frontend/modules/blog/actions/actions.class.php
  class blogActions extends sfActions
  {
    function executeShow()
    {
      $id = $this->getRequestParameter('id');
      $this->post = PostPeer::retrieveByPk($id);              MVC
      $this->forward404Unless($this->post);         Model / View / Controller
    }                                                          XSS
  }     shortcut                                       Secure by default


  # apps/frontend/modules/post/templates/showSuccess.php
  <h1 class="title"><?php echo $post->getTitle() ?></h1>
  <h2>par <?php echo $post->getAuthor()->getFullName() ?></h2>
  <p><?php echo $post->getHtmlContent(ESC_RAW) ?></p>

PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Debugging tools
  • Web Debug Toolbar




PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Debugging tools
  • Error messages




PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Deployment
  $ ./symfony test-all
  functional/frontend/postActionsTest......................ok
  All tests successful.
  Files=1, Tests=2

  # config/properties.ini
  [production]                                                                  $ ./symfony freeze
    host=1.2.3.4
    user=fabien
    dir=/var/www/sfblog
    type=rsync

  $ ./symfony sync production go


PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Community Plugins
  • New plugins are created every week
         – Doctrine : Full Doctrine ORM support
         – UJS : Unobtrusive JavaScript
         – PropelActAsNestedSetBehavior : Nested sets for
           Propel
         – SuperCache : HTML pages cache
         – ControlPanel : Web management for symfony projects
         – ErrorLogger : All 404 and 500 logging in a table
         – Guard : Authentication and authorization features
         – Feed2 : Web feeds management
         – PokaYoke : Client side validation
PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
What’s next?
  • Forge : www.symfony-forge.com
  • New features for symfony 1.1 :
         –   More hooks for plugins
         –   More modularity
         –   Doctrine support
         –   Unobstrusive JavaScript support
         –   New form and validation framework
  • Book translation
                                  , Deutsch, Español, Français
                             Polski, Russian,      , Italiano, …


PHP Quebec 2007      www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
A Professional Web Framework
  • Built from experience
  • 1.0 stable, maintained with commercial support
  • Growing community
         – Developpers in more than 80 countries
         – 100 000 visitors per month on symfony-project.com
  • Open-Source Documentation
         – The book (450 pages - GFDL)
         – Askeet Tutorial (250 pages)


PHP Quebec 2007      www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
A symfony User
  • Yahoo! (USA)
         – Yahoo! Bookmarks
         – 20 millions users
         – Web 2.0 / AJAX




PHP Quebec 2007   www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com
Rejoignez-nous - Join Us
  • 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.

PHP Quebec 2007    www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.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.sensio.com/                                    http://www.symfony-project.com/
PHP Quebec 2007     www.symfony-project.com   fabien.potencier@sensio.com   www.sensio.com

Contenu connexe

Similaire à symfony: Simplify your professional web development with PHP (Symfony PHP Quebec 2007)

Write Plugins for symfony (Symfony Camp 2007)
Write Plugins for symfony (Symfony Camp 2007)Write Plugins for symfony (Symfony Camp 2007)
Write Plugins for symfony (Symfony Camp 2007)Fabien Potencier
 
Continuous Integration Step-by-step
Continuous Integration Step-by-stepContinuous Integration Step-by-step
Continuous Integration Step-by-stepMichelangelo van Dam
 
Debugging with Zend Studio for Eclipse
Debugging with Zend Studio for EclipseDebugging with Zend Studio for Eclipse
Debugging with Zend Studio for EclipseOSSCube
 
PHP in the Real World
PHP in the Real WorldPHP in the Real World
PHP in the Real WorldIvo Jansch
 
Myphp-busters: symfony framework (PHPCon.it)
Myphp-busters: symfony framework (PHPCon.it)Myphp-busters: symfony framework (PHPCon.it)
Myphp-busters: symfony framework (PHPCon.it)Stefan Koopmanschap
 
Plugin-able POS Solutions by Javascript @HDM9 Taiwan
Plugin-able POS Solutions by Javascript @HDM9 TaiwanPlugin-able POS Solutions by Javascript @HDM9 Taiwan
Plugin-able POS Solutions by Javascript @HDM9 TaiwanRack Lin
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Coursepeter_marklund
 
Minko - Scripting 3D apps with Lua and C++
Minko - Scripting 3D apps with Lua and C++Minko - Scripting 3D apps with Lua and C++
Minko - Scripting 3D apps with Lua and C++Minko3D
 
Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opmisnull
 
Symfony workshop introductory slides
Symfony workshop introductory slidesSymfony workshop introductory slides
Symfony workshop introductory slidesStefan Koopmanschap
 
Myphp-busters: symfony framework
Myphp-busters: symfony frameworkMyphp-busters: symfony framework
Myphp-busters: symfony frameworkStefan Koopmanschap
 
IBM IMPACT 2009 Conference Session 2078 - Extending and Integrating Popular P...
IBM IMPACT 2009 Conference Session 2078 - Extending and Integrating Popular P...IBM IMPACT 2009 Conference Session 2078 - Extending and Integrating Popular P...
IBM IMPACT 2009 Conference Session 2078 - Extending and Integrating Popular P...Robert Nicholson
 
Presentation eXo Foss Bridge
Presentation eXo Foss BridgePresentation eXo Foss Bridge
Presentation eXo Foss BridgeJeremi Joslin
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformSébastien Morel
 
Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?AFUP_Limoges
 
Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)Ivo Jansch
 
Earnings With Foss - Joebert
Earnings With Foss - JoebertEarnings With Foss - Joebert
Earnings With Foss - Joebertsoss
 

Similaire à symfony: Simplify your professional web development with PHP (Symfony PHP Quebec 2007) (20)

Write Plugins for symfony (Symfony Camp 2007)
Write Plugins for symfony (Symfony Camp 2007)Write Plugins for symfony (Symfony Camp 2007)
Write Plugins for symfony (Symfony Camp 2007)
 
Continuous Integration Step-by-step
Continuous Integration Step-by-stepContinuous Integration Step-by-step
Continuous Integration Step-by-step
 
Debugging with Zend Studio for Eclipse
Debugging with Zend Studio for EclipseDebugging with Zend Studio for Eclipse
Debugging with Zend Studio for Eclipse
 
PHP in the Real World
PHP in the Real WorldPHP in the Real World
PHP in the Real World
 
Myphp-busters: symfony framework (PHPCon.it)
Myphp-busters: symfony framework (PHPCon.it)Myphp-busters: symfony framework (PHPCon.it)
Myphp-busters: symfony framework (PHPCon.it)
 
Plugin-able POS Solutions by Javascript @HDM9 Taiwan
Plugin-able POS Solutions by Javascript @HDM9 TaiwanPlugin-able POS Solutions by Javascript @HDM9 Taiwan
Plugin-able POS Solutions by Javascript @HDM9 Taiwan
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Minko - Scripting 3D apps with Lua and C++
Minko - Scripting 3D apps with Lua and C++Minko - Scripting 3D apps with Lua and C++
Minko - Scripting 3D apps with Lua and C++
 
Dutch php conference_2010_opm
Dutch php conference_2010_opmDutch php conference_2010_opm
Dutch php conference_2010_opm
 
Symfony workshop introductory slides
Symfony workshop introductory slidesSymfony workshop introductory slides
Symfony workshop introductory slides
 
Myphp-busters: symfony framework
Myphp-busters: symfony frameworkMyphp-busters: symfony framework
Myphp-busters: symfony framework
 
Developing Software That Matters I
Developing Software That Matters IDeveloping Software That Matters I
Developing Software That Matters I
 
IBM IMPACT 2009 Conference Session 2078 - Extending and Integrating Popular P...
IBM IMPACT 2009 Conference Session 2078 - Extending and Integrating Popular P...IBM IMPACT 2009 Conference Session 2078 - Extending and Integrating Popular P...
IBM IMPACT 2009 Conference Session 2078 - Extending and Integrating Popular P...
 
Presentation eXo Foss Bridge
Presentation eXo Foss BridgePresentation eXo Foss Bridge
Presentation eXo Foss Bridge
 
Puppet NBLUG 2008-09
Puppet NBLUG 2008-09Puppet NBLUG 2008-09
Puppet NBLUG 2008-09
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ Platform
 
Symfony for non-techies
Symfony for non-techiesSymfony for non-techies
Symfony for non-techies
 
Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?
 
Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)
 
Earnings With Foss - Joebert
Earnings With Foss - JoebertEarnings With Foss - Joebert
Earnings With Foss - Joebert
 

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.4Fabien Potencier
 
Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Fabien 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.3Fabien Potencier
 
The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010Fabien Potencier
 
Dependency injection - phpday 2010
Dependency injection - phpday 2010Dependency injection - phpday 2010
Dependency injection - phpday 2010Fabien Potencier
 
Dependency Injection IPC 201
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201Fabien Potencier
 
Caching on the Edge with Symfony2
Caching on the Edge with Symfony2Caching on the Edge with Symfony2
Caching on the Edge with Symfony2Fabien Potencier
 
Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2Fabien Potencier
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 WorldFabien Potencier
 
Dependency Injection - ConFoo 2010
Dependency Injection - ConFoo 2010Dependency Injection - ConFoo 2010
Dependency Injection - ConFoo 2010Fabien 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

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Dernier (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

symfony: Simplify your professional web development with PHP (Symfony PHP Quebec 2007)

  • 1. symfony Simplify your professional web development with PHP Fabien Potencier http://www.symfony-project.com/ http://www.sensio.com/ PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 2. Sensio • French Web Agency, founded in 1998 – 150 people – 30 people dedicated to Web technologies SENSIO Web Agency Web Webmarketing Technologies Open Source Technologies (Framework PHP) PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 3. Sensio Labs • Open-Source technologies (LAMP stack) – Linux – Apache – MySQL / PostgreSQL – PHP / Perl / Python / Ruby • Open-Source dedicated team • Big company customers – Web Consulting symfony – Audit / Training PHP Framework – Web Development PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 4. symfony • PHP 5 Web Framework • Based on 9 years of Sensio experience • Based on well-known projets (Mojavi, Propel, Prado) • Open-Source Licence • Built for : MIT – Professional Websites – Complex needs Bring together – Demanding environments Entreprise World Open-Source World PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 5. Don’t reinvent the wheel • Follow best practices • MVC Pattern : Model / View / Controller • Unit and functional test framework • Environment and deployment support • Security (XSS protection by default) • Extensible (plugin system) simplify your life PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 6. Develop faster • Each line of code has a cost – To write the line less code  – To test it less complexity – To maintain it  less bugs • Write less code  – Architecture : controller, ORM, … more productivity  – Configuration more time – Autoloading – Generators – Helpers • More time for business rules, edge cases, … PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 7. Main selling points • Documentation • Configurability • XSS protection Standard • Debugging tools PHP 5 MVC • Functional tests Routing • Extensibility : Plugins Cache • Admin Generator • ORM : Propel or Doctrine • i18n / l10n • 1.0 maintained for a long time PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 8. Symfony installation • PEAR $ pear channel-discover pear.symfony-project.com $ pear install symfony/symfony-1.0.0 PEAR package Subversion easy Package • SVN / symlink Sandbox $ svn propedit svn:externals symfony http://svn.symfony-project.com/branches/1.0 recommended • Sandbox $ curl -O http://www.symfony-project.com/get/sf_sandbox-1.0.0.tgz $ tar zxpf sf_sandbox-1.0.0.tgz fast PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 9. Application Creation $ mkdir ~/sfdemo $ cd ~/sfdemo Project  $ symfony init-project sfdemo Application(s)  $ ./symfony init-app frontend Module(s)  Action(s) Composant(s)  Template PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 10. Database • Database configuration # config/databases.yml prod: Environment propel: support param: password: PAssWD all: propel: class: sfPropelDatabase param: dsn: mysql://root:@localhost/sfdemo • Schema definition SQL abstraction # config/schema.yml post: title: { type: varchar, size: 255 } content: { type: longvarchar } is_published: { type: boolean } author_id: { type: integer, foreignTable: author, foreignReference: id } created_at: ~ PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 11. Database • Test data # data/fixtures/data.yml Author: fabien: first_name: Fabien last_name: Potencier Post: 1) Creates model classes first_post: 2) Converts schema to SQL author_id: fabien 3) Creates tables title: PHP Québec 4) Loads test data $ ./symfony propel-build-all-load frontend PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 12. Model // lib/model/Author.php class Author extends BaseAuthor { function getFullName() { return $this->getFirstName().' '.$this->getLastName(); } } $author = new Author(); $author->setFirstName('Fabien'); ORM $author->setLastName('Potencier'); Object Relationship Mapping $author->save(); Propel / Doctrine $post = new Post(); $post->setAuthor($author); $post->setPublishedOn('12:00 tomorrow'); $post->isPublished(true); $post->save(); $posts = PostPeer::doSelect(new Criteria()); PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 13. Backend creation • Automatic creation of an Administration Backend, ready for production – Lists – Filters Generated code is MVC and customizable – Pagination – Validation Configuration file Controller – Tri – CRUD Templates $ ./symfony propel-init-admin frontend post Post 1) Creates a post module 2) Generates configuration PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 14. Configurability • Module level # apps/frontend/modules/post/config/generator.yml generator: class: sfPropelAdminGenerator param: Configuration model_class: Post Framework list: Project display: [=title, author, created_at] Application filters: [title, author_id, published_on] max_per_page: 5 Module • Application level # apps/frontend/config/security.yml default: is_secure: on credentials: admin LOC : 0 $ ./symfony plugin-install http://plugins.symfony-project.com/sfGuardPlugin PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 15. Admin Generator • List PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 16. Admin Generator • Edition __toString() widgets m2m relationship PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 17. Extensibility • Module extension class postActions extends autoPostActions { protected function addFiltersCriteria($c) Generated { module parent::addFiltersCriteria($c); $c->add(PostPeer::IS_PUBLISHED, true); } } • Template customization _edit_* : actions, footer, form, header, messages _list_* : footer, header, messages, td_actions, t(d|h)_stacked, t(d|h)_tabular _filters, editSuccess, listSuccess PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 18. Frontend Creation • Routing homepage: / param: { module: blog, action: recent } <?php echo url_for('@homepage') ?> url: / homepage: / param: { module: blog, action: list } url: / recent: /recent param: { module: blog, action: recent } url: /recent post: <?php echo link_to( param: { module: blog, action: show } $post->getTitle(), /blog/1.html requirements: '@post?id=’.$post->getId() id: d+ ) ?> url: /blog/:id.html PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 19. Functional Tests • Navigation simulation // test/functional/frontend/blogActionsTest.php $browser = new sfTestBrowser(); $browser->initialize(); TDD $browser-> Test Driven Development get('/blog/1.html')-> isStatusCode(200)-> checkResponseElement('h1.title', '/PHP Québec/'); $ ./symfony test-functional frontend CSS Selector # get / ok 1 - status code is 200 not ok 2 - response selector h1 does not match regex /PHP Québec/ # Looks like you failed 1 tests of 2 1..2 PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 20. Our first line of code # apps/frontend/modules/blog/actions/actions.class.php class blogActions extends sfActions { function executeShow() { $id = $this->getRequestParameter('id'); $this->post = PostPeer::retrieveByPk($id); MVC $this->forward404Unless($this->post); Model / View / Controller } XSS } shortcut Secure by default # apps/frontend/modules/post/templates/showSuccess.php <h1 class="title"><?php echo $post->getTitle() ?></h1> <h2>par <?php echo $post->getAuthor()->getFullName() ?></h2> <p><?php echo $post->getHtmlContent(ESC_RAW) ?></p> PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 21. Debugging tools • Web Debug Toolbar PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 22. Debugging tools • Error messages PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 23. Deployment $ ./symfony test-all functional/frontend/postActionsTest......................ok All tests successful. Files=1, Tests=2 # config/properties.ini [production] $ ./symfony freeze host=1.2.3.4 user=fabien dir=/var/www/sfblog type=rsync $ ./symfony sync production go PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 24. Community Plugins • New plugins are created every week – Doctrine : Full Doctrine ORM support – UJS : Unobtrusive JavaScript – PropelActAsNestedSetBehavior : Nested sets for Propel – SuperCache : HTML pages cache – ControlPanel : Web management for symfony projects – ErrorLogger : All 404 and 500 logging in a table – Guard : Authentication and authorization features – Feed2 : Web feeds management – PokaYoke : Client side validation PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 25. What’s next? • Forge : www.symfony-forge.com • New features for symfony 1.1 : – More hooks for plugins – More modularity – Doctrine support – Unobstrusive JavaScript support – New form and validation framework • Book translation , Deutsch, Español, Français Polski, Russian, , Italiano, … PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 26. A Professional Web Framework • Built from experience • 1.0 stable, maintained with commercial support • Growing community – Developpers in more than 80 countries – 100 000 visitors per month on symfony-project.com • Open-Source Documentation – The book (450 pages - GFDL) – Askeet Tutorial (250 pages) PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 27. A symfony User • Yahoo! (USA) – Yahoo! Bookmarks – 20 millions users – Web 2.0 / AJAX PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 28. Rejoignez-nous - Join Us • 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. PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com
  • 29. 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.sensio.com/ http://www.symfony-project.com/ PHP Quebec 2007 www.symfony-project.com fabien.potencier@sensio.com www.sensio.com