SlideShare a Scribd company logo
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
Ad

More Related Content

Similar to 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)
Fabien Potencier
 
Continuous Integration Step-by-step
Continuous Integration Step-by-stepContinuous Integration Step-by-step
Continuous Integration Step-by-step
Michelangelo van Dam
 
Debugging with Zend Studio for Eclipse
Debugging with Zend Studio for EclipseDebugging with Zend Studio for Eclipse
Debugging with Zend Studio for Eclipse
OSSCube
 
PHP in the Real World
PHP in the Real WorldPHP in the Real World
PHP in the Real World
Ivo 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 Taiwan
Rack 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 Course
peter_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_opm
isnull
 
Symfony workshop introductory slides
Symfony workshop introductory slidesSymfony workshop introductory slides
Symfony workshop introductory slides
Stefan Koopmanschap
 
Myphp-busters: symfony framework
Myphp-busters: symfony frameworkMyphp-busters: symfony framework
Myphp-busters: symfony framework
Stefan Koopmanschap
 
Developing Software That Matters I
Developing Software That Matters IDeveloping Software That Matters I
Developing Software That Matters I
Gneuromante canalada.org
 
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 Bridge
Jeremi Joslin
 
Puppet NBLUG 2008-09
Puppet NBLUG 2008-09Puppet NBLUG 2008-09
Puppet NBLUG 2008-09
Eric Eisenhart
 
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
Sébastien Morel
 
Symfony for non-techies
Symfony for non-techiesSymfony for non-techies
Symfony for non-techies
Stefan Koopmanschap
 
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 - Joebert
soss
 
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-step
Michelangelo van Dam
 
Debugging with Zend Studio for Eclipse
Debugging with Zend Studio for EclipseDebugging with Zend Studio for Eclipse
Debugging with Zend Studio for Eclipse
OSSCube
 
PHP in the Real World
PHP in the Real WorldPHP in the Real World
PHP in the Real World
Ivo 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 Taiwan
Rack 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 Course
peter_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_opm
isnull
 
Symfony workshop introductory slides
Symfony workshop introductory slidesSymfony workshop introductory slides
Symfony workshop introductory slides
Stefan Koopmanschap
 
Myphp-busters: symfony framework
Myphp-busters: symfony frameworkMyphp-busters: symfony framework
Myphp-busters: symfony framework
Stefan 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 Bridge
Jeremi 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 Platform
Sé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 - Joebert
soss
 

More from Fabien Potencier (20)

Varnish
VarnishVarnish
Varnish
Fabien Potencier
 
Look beyond PHP
Look beyond PHPLook beyond PHP
Look beyond PHP
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
 
Caching on the Edge
Caching on the EdgeCaching on the Edge
Caching on the Edge
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
 
PhpBB meets Symfony2
PhpBB meets Symfony2PhpBB meets Symfony2
PhpBB meets Symfony2
Fabien Potencier
 
Dependency injection - phpday 2010
Dependency injection - phpday 2010Dependency injection - phpday 2010
Dependency injection - phpday 2010
Fabien Potencier
 
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
Fabien Potencier
 
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
Fabien Potencier
 
Symfony2 - OSIDays 2010
Symfony2 - OSIDays 2010Symfony2 - OSIDays 2010
Symfony2 - OSIDays 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
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
Fabien Potencier
 
Symfony Components
Symfony ComponentsSymfony Components
Symfony Components
Fabien Potencier
 
PHP 5.3 in practice
PHP 5.3 in practicePHP 5.3 in practice
PHP 5.3 in practice
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
 
Ad

Recently uploaded (20)

Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Social Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTechSocial Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTech
Steve Jonas
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Social Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTechSocial Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTech
Steve Jonas
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
Ad

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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] www.sensio.com
  • 15. Admin Generator • List PHP Quebec 2007 www.symfony-project.com [email protected] www.sensio.com
  • 16. Admin Generator • Edition __toString() widgets m2m relationship PHP Quebec 2007 www.symfony-project.com [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] www.sensio.com
  • 21. Debugging tools • Web Debug Toolbar PHP Quebec 2007 www.symfony-project.com [email protected] www.sensio.com
  • 22. Debugging tools • Error messages PHP Quebec 2007 www.symfony-project.com [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] 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 [email protected] http://www.sensio.com/ http://www.symfony-project.com/ PHP Quebec 2007 www.symfony-project.com [email protected] www.sensio.com