SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
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

Más contenido relacionado

Similar a 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
 

Similar a 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
 

Más 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
 

Más 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
 

Último

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
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Último (20)

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 ...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

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