SlideShare a Scribd company logo
1 of 59
Download to read offline
Build smart and powerful web
 applications with Symfony2
Built around standalone and
 decoupled components…
… and a full-stack framework based
     on those components
Application bundles                  Third party bundles


                    The Symfony2 stack

     Core Bundles                       Third party libraries


                    Standalone Components
« A Bundle is a directory that has a well-de ned
structure and can host anything from classes to
       controllers and web resources.  »
What makes Symfony2 unique?
Symfony2 follows standards
     & best practices

      -  RFC2616
      -  PHPUnit
   -  Jinja Templates
   -  Design Patterns
Symfony is now easier
 to install and con gure

http://symfony.com/download
Several distributions available
      Download the Standard Edition that hosts the
      framework, standard bundles and a default application
      architecture.
Easy installation and con guration
Web con guration

Con gure the database access parameters
Start to use Symfony2 and happy coding J
Want to give it a try?
Symfony2 Philosophy



    « Basically, Symfony2 asks you to
   convert a Request into a Response »
Request handling

  class DefaultController extends Controller
  {
      /**
        * @extra:Route("/hello/{name}")
        */
      public function indexAction($name)
      {
           // ... do things

          return new Response(sprintf('Hello %s!', $name));
      }
  }
Request handling

 class DefaultController extends Controller
 {
     /**
       * @extra:Route("/hello/{name}")
       */
     public function indexAction($name)
     {
          // ... do things

         return $this->render('HelloBundle:Default:index.html.twig',
 array('name' => $name));
     }
 }
Request handling

    class DefaultController extends Controller
    {
        /**
          * @extra:Route("/schedule")
          * @extra:Template
          */
        public function indexAction()
        {
             $title = 'Confoo 2011 Conferences Schedule';

            return array('title' => $title);
        }
    }
Templating
{% extends "ConfooConferenceBundle::layout.html.twig" %}

{% block content %}

    <h1> {{ title }} </h1>

    <ul>
        <li>Caching on the Edge, by Fabien Potencier</li>
        <li>HipHop for PHP, by Scott Mac Vicar</li>
        <li>XDebug, by Derick Rethans</li>
        <li>...</li>
    </ul>

{% endblock %}
TWIG Template Engine
Twig is a modern template engine for PHP

       §  Fast
       §  Concise and rich syntax
       §  Automatic output escaping
       §  Modern features
       §  Extensible
       §  Flexible
Template inheritance
{% extends "ConfooConferenceBundle::layout.html.twig" %}

{% block content %}

    <h1> {{ title }} </h1>

    <ul>
        <li>Caching on the Edge, by Fabien Potencier</li>
        <li>HipHop for PHP, by Scott Mac Vicar</li>
        <li>XDebug, by Derick Rethans</li>
        <li>...</li>
    </ul>

{% endblock %}
Template inheritance

{% extends "::base.html.twig"   %}

{% block body %}

    <img src="/images/logo.gif" alt="Confoo 2011"/>

    {% block content %}{% endblock %}

{% endblock %}
Template inheritance

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type"
            content="text/html; charset=utf-8" />

        <title>{% block title %}Welcome!{% endblock %}</title>

        <link rel="shortcut icon" href="{{ asset('favicon.ico') }}" />
    </head>
    <body>
        {% block body %}{% endblock %}
    </body>
</html>
Template inheritance

 base.html.twig
                              layout.html.twig




                       index.html.twig
Smart URIs
Smart URIs




             Typical PHP URIs suck!!!
Smart URIs




        Native routing mechanism
Smart URIs
 class DefaultController extends Controller
 {
     /**
       * @extra:Route("/{year}/talk/{month}/{day}/{slug}")
       * @extra:Template
       */
     public function showAction($slug, $day, $month, $year)
     {
          // Get a talk object from the database
          $talk = ...;

         return array('talk' => $talk);
     }
 }
Parameter converter

 class DefaultController extends Controller
 {
     /**
       * @extra:Route("/talk/{id}")
       * @extra:Template
       */
     public function showAction(Talk $talk)
     {
          return array('talk' => $talk);
     }
 }
Easy Debugging
The Web Debug Toolbar




Symfony2 version environment environment
            PHP          Current           Current response RecordedTimers Memory
                                                                     logs     Queries
Exception stack traces
Exception stack traces
Recorded logs
The Pro ler application
The Pro ler application
Database Management
Doctrine 2 Library

 §  Database Abstraction Layer on top of PDO
 §  Object Relational Mapper
 §  Migrations support
 §  Object Document Mapper (MongoDB)
 §  Object XML Mapper (XML databases)
De ning entities as POPO
/**	
  * @orm:Entity	
  */	
class Talk	
{	
      /**	
       * @orm:Id	
       * @orm:GeneratedValue	
       * @orm:Column(type="integer")	
       */	
      public $id;	
	
      /** @orm:Column(length=80, nullable=false) */	
      public $title;	
	
      /** @orm:Column(type="text") */	
      public $synopsis;	
	
      /** @orm:Column(type="datetime") */	
      public $schedule;	
	
      /** @orm:ManyToMany(targetEntity="Speaker", mappedBy="talks") */	
      public $speakers;	
}
Validation
Validation


   §  Validate POPOs (properties & methods)

   §  Easy con guration with annotations

   §  Easy to customize and extend
Validating Plain PHP Objects

        class ContactRequest
        {
            /** @validation:NotBlank */
            public $message;

                /**
                 * @validation:Email
                 * @validation:NotBlank
                 */
                public $sender;
            }
        }
Forms Handling
Forms management

§  Transparent layer on top of your domain object

§  Native CSRF protection

§  Coupled to the Validation framework

§  Twig integration
Designing a basic form class

     namespace ConfooContactBundleForm;

     use   SymfonyComponentFormForm;
     use   SymfonyComponentFormTextField;
     use   SymfonyComponentFormTextareaField;
     use   SymfonyComponentFormCheckboxField;

     class ContactForm extends Form
     {
         protected function configure()
         {
             $this->add(new TextField('sender')));
             $this->add(new TextareaField('message'));
         }
     }
Processing a form
   public function contactAction()
   {
       $contactRequest = new ContactRequest();

       $form = ContactForm::create(...);

       $form->bind($this->get('request'), $contactRequest);

       if ($form->isValid()) {

           // do things with validated data
       }

       return array('form' => $form);
   }
Prototyping the rendering with Twig

 {% extends 'ConfooContactBundle::layout.html.twig' %}

 {% block content %}

 <form action="#" method="post">

    {{ form_field(form) }}

    <input type="submit" value="Send!" />

 </form>

 {% endblock %}
Functional Testing
Functional testing



     Simulating an end-user browsing
     scenario and testing the Response
Functional Testing

class DefaultControllerTest extends WebTestCase
{
    public function testIndex()
    {
        $client = $this->createClient();

        $crawler = $client->request('GET', '/schedule');

        $this->assertTrue(
            $crawler->filter('html:contains("Fabien Potencier")')->count() > 0
        );

        $this->assertTrue($client->getResponse()->headers->has('expires'));
    }
}
HTTP Compliance (RFC2616)
Expiration / Validation
Expiration with Expires

    class DefaultController extends Controller
    {
        /**
          * @extra:Route("/schedule")
          * @extra:Template
          * @extra:Cache(expires="tomorrow")
          */
        public function indexAction()
        {
             $title = 'Confoo 2011 Conferences Schedule';

            return array('title' => $title);
        }
    }
Expiration with Cache-Control

    class DefaultController extends Controller
    {
        /**
          * @extra:Route("/schedule")
          * @extra:Template
          * @extra:Cache(maxage="20", s-maxage="20")
          */
        public function indexAction()
        {
             $title = 'Confoo 2011 Conferences Schedule';

            return array('title' => $title);
        }
    }
Native PHP Reverse Proxy Cache
Varnish / Squid
Edge Side Includes

<esi:include src="http://..." />
Security
Authentication & Authorization
Thank You!

More Related Content

What's hot

Design pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentesDesign pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentesGiulio De Donato
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 
A peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk UserA peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk UserKoan-Sin Tan
 
Running a Plone product on Substance D
Running a Plone product on Substance DRunning a Plone product on Substance D
Running a Plone product on Substance DMakina Corpus
 
TMAPI 2.0 tutorial
TMAPI 2.0 tutorialTMAPI 2.0 tutorial
TMAPI 2.0 tutorialtmra
 
Coder sans peur du changement avec la meme pas mal hexagonal architecture
Coder sans peur du changement avec la meme pas mal hexagonal architectureCoder sans peur du changement avec la meme pas mal hexagonal architecture
Coder sans peur du changement avec la meme pas mal hexagonal architectureThomas Pierrain
 
Repoze Bfg - presented by Rok Garbas at the Python Barcelona Meetup October 2...
Repoze Bfg - presented by Rok Garbas at the Python Barcelona Meetup October 2...Repoze Bfg - presented by Rok Garbas at the Python Barcelona Meetup October 2...
Repoze Bfg - presented by Rok Garbas at the Python Barcelona Meetup October 2...maikroeder
 
Getting big without getting fat, in perl
Getting big without getting fat, in perlGetting big without getting fat, in perl
Getting big without getting fat, in perlDean Hamstead
 
Annotations in PHP: They Exist
Annotations in PHP: They ExistAnnotations in PHP: They Exist
Annotations in PHP: They ExistRafael Dohms
 
Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Elizabeth Smith
 
Reverse Engineering in Linux - The tools showcase
Reverse Engineering in Linux - The tools showcaseReverse Engineering in Linux - The tools showcase
Reverse Engineering in Linux - The tools showcaseLevis Nickaster
 
Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginnersAdam Englander
 
Introduction to Groovy Monkey
Introduction to Groovy MonkeyIntroduction to Groovy Monkey
Introduction to Groovy Monkeyjervin
 
Dependency Injection for Wordpress
Dependency Injection for WordpressDependency Injection for Wordpress
Dependency Injection for Wordpressmtoppa
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPtutorialsruby
 

What's hot (20)

Design pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentesDesign pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentes
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
A peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk UserA peek into Python's Metaclass and Bytecode from a Smalltalk User
A peek into Python's Metaclass and Bytecode from a Smalltalk User
 
Running a Plone product on Substance D
Running a Plone product on Substance DRunning a Plone product on Substance D
Running a Plone product on Substance D
 
TMAPI 2.0 tutorial
TMAPI 2.0 tutorialTMAPI 2.0 tutorial
TMAPI 2.0 tutorial
 
Coder sans peur du changement avec la meme pas mal hexagonal architecture
Coder sans peur du changement avec la meme pas mal hexagonal architectureCoder sans peur du changement avec la meme pas mal hexagonal architecture
Coder sans peur du changement avec la meme pas mal hexagonal architecture
 
Repoze Bfg - presented by Rok Garbas at the Python Barcelona Meetup October 2...
Repoze Bfg - presented by Rok Garbas at the Python Barcelona Meetup October 2...Repoze Bfg - presented by Rok Garbas at the Python Barcelona Meetup October 2...
Repoze Bfg - presented by Rok Garbas at the Python Barcelona Meetup October 2...
 
Wt unit 5
Wt unit 5Wt unit 5
Wt unit 5
 
Getting big without getting fat, in perl
Getting big without getting fat, in perlGetting big without getting fat, in perl
Getting big without getting fat, in perl
 
Annotations in PHP: They Exist
Annotations in PHP: They ExistAnnotations in PHP: They Exist
Annotations in PHP: They Exist
 
Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Spl in the wild - zendcon2012
Spl in the wild - zendcon2012
 
Reverse Engineering in Linux - The tools showcase
Reverse Engineering in Linux - The tools showcaseReverse Engineering in Linux - The tools showcase
Reverse Engineering in Linux - The tools showcase
 
Php task runners
Php task runnersPhp task runners
Php task runners
 
Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginners
 
The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 
Introduction to Groovy Monkey
Introduction to Groovy MonkeyIntroduction to Groovy Monkey
Introduction to Groovy Monkey
 
Php go vrooom!
Php go vrooom!Php go vrooom!
Php go vrooom!
 
Dependency Injection for Wordpress
Dependency Injection for WordpressDependency Injection for Wordpress
Dependency Injection for Wordpress
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 

Viewers also liked

Symfony ile Gelişmiş API Mimarisi
Symfony ile Gelişmiş API MimarisiSymfony ile Gelişmiş API Mimarisi
Symfony ile Gelişmiş API MimarisiBehram ÇELEN
 
PHP Symfony ile Güzel
PHP Symfony ile GüzelPHP Symfony ile Güzel
PHP Symfony ile GüzelEmre YILMAZ
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
Symfony2 en pièces détachées
Symfony2 en pièces détachéesSymfony2 en pièces détachées
Symfony2 en pièces détachéesHugo Hamon
 
Développeurs, cachez-moi ça ! (Paris Web 2011)
Développeurs, cachez-moi ça ! (Paris Web 2011)Développeurs, cachez-moi ça ! (Paris Web 2011)
Développeurs, cachez-moi ça ! (Paris Web 2011)Hugo Hamon
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistenceHugo Hamon
 
Designing for developers
Designing for developersDesigning for developers
Designing for developersKirsten Hunter
 
This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?
This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?
This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?Mark Heckler
 
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleDesign Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleHugo Hamon
 
Symfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 PerformantSymfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 PerformantHugo Hamon
 
Monitor the quality of your Symfony projects
Monitor the quality of your Symfony projectsMonitor the quality of your Symfony projects
Monitor the quality of your Symfony projectsHugo Hamon
 
API 101 Workshop from APIStrat Conference
API 101 Workshop from APIStrat ConferenceAPI 101 Workshop from APIStrat Conference
API 101 Workshop from APIStrat ConferenceKirsten Hunter
 
Prototyping in the cloud
Prototyping in the cloudPrototyping in the cloud
Prototyping in the cloudKirsten Hunter
 

Viewers also liked (20)

Symfony ile Gelişmiş API Mimarisi
Symfony ile Gelişmiş API MimarisiSymfony ile Gelişmiş API Mimarisi
Symfony ile Gelişmiş API Mimarisi
 
PHP Symfony ile Güzel
PHP Symfony ile GüzelPHP Symfony ile Güzel
PHP Symfony ile Güzel
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Liberating your data
Liberating your dataLiberating your data
Liberating your data
 
Liberating your data
Liberating your dataLiberating your data
Liberating your data
 
Symfony2 en pièces détachées
Symfony2 en pièces détachéesSymfony2 en pièces détachées
Symfony2 en pièces détachées
 
Développeurs, cachez-moi ça ! (Paris Web 2011)
Développeurs, cachez-moi ça ! (Paris Web 2011)Développeurs, cachez-moi ça ! (Paris Web 2011)
Développeurs, cachez-moi ça ! (Paris Web 2011)
 
Api 101
Api 101Api 101
Api 101
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
 
API First
API FirstAPI First
API First
 
Designing for developers
Designing for developersDesigning for developers
Designing for developers
 
This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?
This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?
This stuff is cool, but...HOW CAN I GET MY COMPANY TO DO IT?
 
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleDesign Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et Pimple
 
Symfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 PerformantSymfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 Performant
 
Monitor the quality of your Symfony projects
Monitor the quality of your Symfony projectsMonitor the quality of your Symfony projects
Monitor the quality of your Symfony projects
 
API 101 Workshop from APIStrat Conference
API 101 Workshop from APIStrat ConferenceAPI 101 Workshop from APIStrat Conference
API 101 Workshop from APIStrat Conference
 
Facebook appsincloud
Facebook appsincloudFacebook appsincloud
Facebook appsincloud
 
Quantifying fitness
Quantifying fitnessQuantifying fitness
Quantifying fitness
 
Prototyping in the cloud
Prototyping in the cloudPrototyping in the cloud
Prototyping in the cloud
 
Polyglot copy
Polyglot copyPolyglot copy
Polyglot copy
 

Similar to Build powerfull and smart web applications with Symfony2

Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2 Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2 3camp
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenchesLukas Smith
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsMichael Peacock
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207patter
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the TrenchesJonathan Wage
 
Web Components With Rails
Web Components With RailsWeb Components With Rails
Web Components With RailsBoris Nadion
 
Multilingualism makes better programmers
Multilingualism makes better programmersMultilingualism makes better programmers
Multilingualism makes better programmersAlexander Varwijk
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiJérémy Derussé
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationAbdul Malik Ikhsan
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterHaehnchen
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's CodeWildan Maulana
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortalJennifer Bourey
 
SOLID: the core principles of success of the Symfony web framework and of you...
SOLID: the core principles of success of the Symfony web framework and of you...SOLID: the core principles of success of the Symfony web framework and of you...
SOLID: the core principles of success of the Symfony web framework and of you...Vladyslav Riabchenko
 

Similar to Build powerfull and smart web applications with Symfony2 (20)

Symfony2 revealed
Symfony2 revealedSymfony2 revealed
Symfony2 revealed
 
Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2 Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
Web Components With Rails
Web Components With RailsWeb Components With Rails
Web Components With Rails
 
Multilingualism makes better programmers
Multilingualism makes better programmersMultilingualism makes better programmers
Multilingualism makes better programmers
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Asp.net
Asp.netAsp.net
Asp.net
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept Implementation
 
Hexagonal architecture in PHP
Hexagonal architecture in PHPHexagonal architecture in PHP
Hexagonal architecture in PHP
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
SOLID: the core principles of success of the Symfony web framework and of you...
SOLID: the core principles of success of the Symfony web framework and of you...SOLID: the core principles of success of the Symfony web framework and of you...
SOLID: the core principles of success of the Symfony web framework and of you...
 

More from Hugo Hamon

Database Design Patterns
Database Design PatternsDatabase Design Patterns
Database Design PatternsHugo Hamon
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & RESTHugo Hamon
 
Intégration Continue PHP avec Jenkins CI
Intégration Continue PHP avec Jenkins CIIntégration Continue PHP avec Jenkins CI
Intégration Continue PHP avec Jenkins CIHugo Hamon
 
Symfony2 - extending the console component
Symfony2 - extending the console componentSymfony2 - extending the console component
Symfony2 - extending the console componentHugo Hamon
 
Intégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec JenkinsIntégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec JenkinsHugo Hamon
 
Mieux Développer en PHP avec Symfony
Mieux Développer en PHP avec SymfonyMieux Développer en PHP avec Symfony
Mieux Développer en PHP avec SymfonyHugo Hamon
 
Introduction à Symfony2
Introduction à Symfony2Introduction à Symfony2
Introduction à Symfony2Hugo Hamon
 
Exposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
Exposer des services web SOAP et REST avec symfony 1.4 et Zend FrameworkExposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
Exposer des services web SOAP et REST avec symfony 1.4 et Zend FrameworkHugo Hamon
 

More from Hugo Hamon (8)

Database Design Patterns
Database Design PatternsDatabase Design Patterns
Database Design Patterns
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
 
Intégration Continue PHP avec Jenkins CI
Intégration Continue PHP avec Jenkins CIIntégration Continue PHP avec Jenkins CI
Intégration Continue PHP avec Jenkins CI
 
Symfony2 - extending the console component
Symfony2 - extending the console componentSymfony2 - extending the console component
Symfony2 - extending the console component
 
Intégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec JenkinsIntégration continue des projets PHP avec Jenkins
Intégration continue des projets PHP avec Jenkins
 
Mieux Développer en PHP avec Symfony
Mieux Développer en PHP avec SymfonyMieux Développer en PHP avec Symfony
Mieux Développer en PHP avec Symfony
 
Introduction à Symfony2
Introduction à Symfony2Introduction à Symfony2
Introduction à Symfony2
 
Exposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
Exposer des services web SOAP et REST avec symfony 1.4 et Zend FrameworkExposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
Exposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
 

Recently uploaded

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Build powerfull and smart web applications with Symfony2

  • 1. Build smart and powerful web applications with Symfony2
  • 2.
  • 3. Built around standalone and decoupled components…
  • 4. … and a full-stack framework based on those components
  • 5. Application bundles Third party bundles The Symfony2 stack Core Bundles Third party libraries Standalone Components
  • 6. « A Bundle is a directory that has a well-de ned structure and can host anything from classes to controllers and web resources.  »
  • 8. Symfony2 follows standards & best practices -  RFC2616 -  PHPUnit -  Jinja Templates -  Design Patterns
  • 9. Symfony is now easier to install and con gure http://symfony.com/download
  • 10. Several distributions available Download the Standard Edition that hosts the framework, standard bundles and a default application architecture.
  • 11. Easy installation and con guration
  • 12. Web con guration Con gure the database access parameters
  • 13. Start to use Symfony2 and happy coding J
  • 14. Want to give it a try?
  • 15. Symfony2 Philosophy « Basically, Symfony2 asks you to convert a Request into a Response »
  • 16. Request handling class DefaultController extends Controller { /** * @extra:Route("/hello/{name}") */ public function indexAction($name) { // ... do things return new Response(sprintf('Hello %s!', $name)); } }
  • 17. Request handling class DefaultController extends Controller { /** * @extra:Route("/hello/{name}") */ public function indexAction($name) { // ... do things return $this->render('HelloBundle:Default:index.html.twig', array('name' => $name)); } }
  • 18. Request handling class DefaultController extends Controller { /** * @extra:Route("/schedule") * @extra:Template */ public function indexAction() { $title = 'Confoo 2011 Conferences Schedule'; return array('title' => $title); } }
  • 19. Templating {% extends "ConfooConferenceBundle::layout.html.twig" %} {% block content %} <h1> {{ title }} </h1> <ul> <li>Caching on the Edge, by Fabien Potencier</li> <li>HipHop for PHP, by Scott Mac Vicar</li> <li>XDebug, by Derick Rethans</li> <li>...</li> </ul> {% endblock %}
  • 20. TWIG Template Engine Twig is a modern template engine for PHP §  Fast §  Concise and rich syntax §  Automatic output escaping §  Modern features §  Extensible §  Flexible
  • 21. Template inheritance {% extends "ConfooConferenceBundle::layout.html.twig" %} {% block content %} <h1> {{ title }} </h1> <ul> <li>Caching on the Edge, by Fabien Potencier</li> <li>HipHop for PHP, by Scott Mac Vicar</li> <li>XDebug, by Derick Rethans</li> <li>...</li> </ul> {% endblock %}
  • 22. Template inheritance {% extends "::base.html.twig" %} {% block body %} <img src="/images/logo.gif" alt="Confoo 2011"/> {% block content %}{% endblock %} {% endblock %}
  • 23. Template inheritance <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>{% block title %}Welcome!{% endblock %}</title> <link rel="shortcut icon" href="{{ asset('favicon.ico') }}" /> </head> <body> {% block body %}{% endblock %} </body> </html>
  • 24. Template inheritance base.html.twig layout.html.twig index.html.twig
  • 26. Smart URIs Typical PHP URIs suck!!!
  • 27. Smart URIs Native routing mechanism
  • 28. Smart URIs class DefaultController extends Controller { /** * @extra:Route("/{year}/talk/{month}/{day}/{slug}") * @extra:Template */ public function showAction($slug, $day, $month, $year) { // Get a talk object from the database $talk = ...; return array('talk' => $talk); } }
  • 29. Parameter converter class DefaultController extends Controller { /** * @extra:Route("/talk/{id}") * @extra:Template */ public function showAction(Talk $talk) { return array('talk' => $talk); } }
  • 31. The Web Debug Toolbar Symfony2 version environment environment PHP Current Current response RecordedTimers Memory logs Queries
  • 35. The Pro ler application
  • 36. The Pro ler application
  • 38. Doctrine 2 Library §  Database Abstraction Layer on top of PDO §  Object Relational Mapper §  Migrations support §  Object Document Mapper (MongoDB) §  Object XML Mapper (XML databases)
  • 39. De ning entities as POPO /** * @orm:Entity */ class Talk { /** * @orm:Id * @orm:GeneratedValue * @orm:Column(type="integer") */ public $id; /** @orm:Column(length=80, nullable=false) */ public $title; /** @orm:Column(type="text") */ public $synopsis; /** @orm:Column(type="datetime") */ public $schedule; /** @orm:ManyToMany(targetEntity="Speaker", mappedBy="talks") */ public $speakers; }
  • 41. Validation §  Validate POPOs (properties & methods) §  Easy con guration with annotations §  Easy to customize and extend
  • 42. Validating Plain PHP Objects class ContactRequest { /** @validation:NotBlank */ public $message; /** * @validation:Email * @validation:NotBlank */ public $sender; } }
  • 44. Forms management §  Transparent layer on top of your domain object §  Native CSRF protection §  Coupled to the Validation framework §  Twig integration
  • 45. Designing a basic form class namespace ConfooContactBundleForm; use SymfonyComponentFormForm; use SymfonyComponentFormTextField; use SymfonyComponentFormTextareaField; use SymfonyComponentFormCheckboxField; class ContactForm extends Form { protected function configure() { $this->add(new TextField('sender'))); $this->add(new TextareaField('message')); } }
  • 46. Processing a form public function contactAction() { $contactRequest = new ContactRequest(); $form = ContactForm::create(...); $form->bind($this->get('request'), $contactRequest); if ($form->isValid()) { // do things with validated data } return array('form' => $form); }
  • 47. Prototyping the rendering with Twig {% extends 'ConfooContactBundle::layout.html.twig' %} {% block content %} <form action="#" method="post"> {{ form_field(form) }} <input type="submit" value="Send!" /> </form> {% endblock %}
  • 49. Functional testing Simulating an end-user browsing scenario and testing the Response
  • 50. Functional Testing class DefaultControllerTest extends WebTestCase { public function testIndex() { $client = $this->createClient(); $crawler = $client->request('GET', '/schedule'); $this->assertTrue( $crawler->filter('html:contains("Fabien Potencier")')->count() > 0 ); $this->assertTrue($client->getResponse()->headers->has('expires')); } }
  • 53. Expiration with Expires class DefaultController extends Controller { /** * @extra:Route("/schedule") * @extra:Template * @extra:Cache(expires="tomorrow") */ public function indexAction() { $title = 'Confoo 2011 Conferences Schedule'; return array('title' => $title); } }
  • 54. Expiration with Cache-Control class DefaultController extends Controller { /** * @extra:Route("/schedule") * @extra:Template * @extra:Cache(maxage="20", s-maxage="20") */ public function indexAction() { $title = 'Confoo 2011 Conferences Schedule'; return array('title' => $title); } }
  • 55. Native PHP Reverse Proxy Cache
  • 57. Edge Side Includes <esi:include src="http://..." />