SlideShare a Scribd company logo
1 of 127
Download to read offline
Symfony2
Fabien Potencier
How many of you have already used symfony1?
How many of you have already played with Symfony2?
What is Symfony2?
A set of decoupled
and cohesive components
DependencyInjection
  EventDispatcher
  HttpFoundation
   OutputEscaper
    DomCrawler
    CssSelector
    Templating
    HttpKernel
    BrowserKit
     Validator
      Routing
      Console
      Process
       Finder
        Form
        Yaml
git clone git://github.com/symfony/symfony.git
A set of decoupled
and cohesive components

    Autoloading
PEAR_Log   >   PEAR/Log.php
          Zend_Log   >   Zend/Log.php
Swift_Mime_Message   >   Swift/Mime/Message.php
     Twig_Node_For   >   Twig/Node/For.php
SymfonyFoundationKernel
          Symfony/Foundation/Kernel.php

                DoctrineDBALDriver
              Doctrine/DBAL/Driver.php

  pdependreflectionReflectionSession
pdepend/reflection/ReflectionSession.php


http://groups.google.com/group/php-standards/web/psr-0-final-proposal	
  
require_once '.../Symfony/Framework/
UniversalClassLoader.php';

use SymfonyFrameworkUniversalClassLoader;

$loader = new UniversalClassLoader();
$loader->register();
$loader->registerNamespaces(array(
  'Symfony' => '/path/to/symfony/src',
  'Doctrine' => '/path/to/doctrine/lib',
  'pdepend' => '/path/to/reflection/source',
));

                                  PHP 5.3 technical
                              interoperability standards
$loader->registerPrefixes(array(
  'Swift_' => '/path/to/swiftmailer/lib/classes',
  'Zend_' => '/path/to/vendor/zend/library',
));


                                    PEAR style
A set of decoupled
and cohesive components

      Process
use SymfonyComponentProcessProcess;

$cmd = 'ssh 1.2.3.4 "ps waux"';

$process = new Process($cmd);
$process->run();

if (!$process->isSuccessful()) {
    throw new RuntimeException(
        $process->getErrorOutput());
}

echo $process->getOutput();
$cmd = 'ssh 1.2.3.4 "tail -f /some/log"';

$process = new Process($cmd);

$process->run(function ($type, $buffer) {
    echo $buffer;
});
use SymfonyComponentProcessPhpProcess;

$process = new PhpProcess(
    '<?php echo "hello"; ?>');
$process->run();

if (!$process->isSuccessful()) {
    throw new RuntimeException(
        $process->getErrorOutput());
}

echo $process->getOutput();
A set of decoupled
and cohesive components

    CssSelector
use SymfonyComponentCssSelectorParser;

Parser::cssToXpath('h4 > a:contains("foo")');
use SymfonyComponentCssSelectorParser;

$document = new DOMDocument();
$document->loadHTMLFile('...');
$xpath = new DOMXPath($document);

$expr = Parser::cssToXpath('a.smart');
$nodes = $xpath->query($expr);

foreach ($nodes as $node)
{
  printf("%s (%s)n", $node->nodeValue, $node-
>getAttribute('href'));
}
A set of decoupled
and cohesive components

       Finder
use SymfonyComponentFinderFinder;

$finder = new Finder();
$finder
    ->files()
    ->in(__DIR__)
    ->...()
    ->sortByName()
;
$finder
    ->name('*.php')
    ->depth('<= 1')
    ->date('>= yesterday')
    ->size('<= 1K')
    ->filter(function (SplFileInfo $file) {
       return strlen($file->getBasename()) < 9;
    })
;
foreach ($finder as $file) {
    print $file->getRealpath()."n";
}

$files = iterator_to_array($finder);

$count = iterator_count($finder);
use SymfonyComponentFinderFinder;

$s3 = new Zend_Service_Amazon_S3($key, $sct);
$s3->registerStreamWrapper("s3");

$finder = new Finder();
$finder
  ->name('photos*')
  ->size('< 100K')
  ->date('since 1 hour ago')
  ->in('s3://bucket-name')
;
A set of decoupled
and cohesive components

      Routing
/blog.php?section=symfony&article_id=18475
web/
  index.php
/index.php/blog/2010/09/18/Symfony2-in-India
/blog/2010/09/18/Symfony2-in-India
/blog/:year/:month/:day/:slug
post:
    pattern: /blog/:year/:month/:day/:slug
    defaults:
      { _controller: BlogBundle:Post:show }
<routes>
    <route
      id="post"
      pattern="/blog/:year/:month/:day/:slug">
      <default key="_controller">
         BlogBundle:Post:show
      </default>
    </route>
</routes>
use SymfonyComponentRoutingRouteCollection;
use SymfonyComponentRoutingRoute;

$collection = new RouteCollection();

$route = new Route(
  '/blog/:year/:month/:day/:slug',
  array('_controller' => 'BlogBundle:Post:show'));

$collection->addRoute('post', $route);

return $collection;
$router
  ->match('/blog/2010/09/18/Symfony2-in-India')



$router
  ->generate('post', array('slug' => '...'))
post:
    pattern: /post/:slug
    defaults:
      { _controller: BlogBundle:Post:show }
$router
  ->generate('post', array('slug' => '...'))
An Object-Oriented abstraction
         on top of PHP
An Object-Oriented abstraction
         on top of PHP

          Request
use SymfonyComponentHttpFoundationRequest;

$request = new Request();

// get a $_GET parameter
$request->query->get('page');

// get a $_POST parameter
$request->request->get('page');

// get a $_COOKIE parameter
$request->cookies->get('name');

$request->getPreferredLanguage(array('en', 'fr'));
$request->isXmlHttpRequest();
// get a $_FILE parameter
$f = $request->files->get('image');

// $f is an instance of
// SymfonyComponentHttpFoundationFileUploadedFile

// guess extension, based on the mime type
$n = '/path/to/file'.$file->getDefaultExtension();
$f->move($n);
new Request();

new Request(
    $_GET, $_POST, array(),
    $_COOKIE, $_FILES, $_SERVER
);

Request::create('/hello/Fabien', 'GET');
An Object-Oriented abstraction
         on top of PHP

          Session
$session = $request->getSession();

$session->set('foo', 'bar');
$session->get('foo');

$session->setFlash('notice', 'Congratulations!');
An Object-Oriented abstraction
         on top of PHP

         Response
use SymfonyComponentHttpFoundationResponse;

$response = new Response('Hello World', 200,
  array('Content-Type' => 'text/plain'));
$response->send();

$response->setHeader('Content-Type', 'text/
plain');
$response->setCookie('foo', 'bar');
$response->setContent('Hello World');
$response->setStatusCode(200);
An Object-Oriented abstraction
       of the HTTP dialog
A MVC Web Framework
The Symfony2 MVC Philosophy
Be as easy as possible for newcomers
and as flexible as possible for advanced users
MVC
http://symfony-reloaded.org/

http://symfony-reloaded.org/downloads/
          sandbox_2_0_PR3.zip
post:
    pattern: /hello/:name
    defaults:
      { _controller: HelloBundle:Hello:index }

namespace ApplicationHelloBundleController;

use SymfonyBundleFrameworkBundleController;

class HelloController extends Controller
{
    public function indexAction($name)
    {
        return new Response('Hello '.$name);
    }
}
namespace ApplicationHelloBundleController;

use SymfonyBundleFrameworkBundleController;

class HelloController extends Controller
{
    public function indexAction($name)
    {
        // Get things from the Model

        return $this->render(
            'HelloBundle:Hello:index',
            array('name' => $name)
        );
    }
}
Hello <?php echo $name ?>!
<?php $view->extend('HelloBundle::layout') ?>

Hello <?php echo $name ?>!
<html>
    <head>
         <title>
           <?php $view['slots']->output('title') ?>
         </title>
    </head>
    <body>
        <?php $view['slots']->output('_content') ?>
    </body>
</html>
slot
                    title

         Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  consectetur	
  adipiscing	
  elit.	
  In	
  vel	
  
                                                                                                  _content
         Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  consectetur	
  adipiscing	
  elit.	
  In	
  vel	
  nulla	
  arcu,	
  
         vitae	
  cursus	
  nunc.	
  Integer	
  semper	
  turpis	
  et	
  enim	
  por6tor	
  iaculis.	
  Nulla	
  
         facilisi.	
  Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  consectetur	
  adipiscing	
  elit.	
  Mauris	
  
         vehicula	
  ves;bulum	
  dictum.	
  Aenean	
  non	
  velit	
  tortor.	
  Nullam	
  adipiscing	
  
         malesuada	
  aliquam.	
  Mauris	
  dignissim,	
  urna	
  quis	
  iaculis	
  tempus,	
  justo	
  
layout   libero	
  por6tor	
  est,	
  nec	
  eleifend	
  est	
  elit	
  vitae	
  ante.	
  Curabitur	
  interdum	
  
         luctus	
  metus,	
  in	
  pulvinar	
  lectus	
  rutrum	
  sit	
  amet.	
  Duis	
  gravida,	
  metus	
  in	
  
         dictum	
  eleifend,	
  dolor	
  risus	
  ;ncidunt	
  ligula,	
  non	
  volutpat	
  nulla	
  sapien	
  in	
  
         elit.	
  Nulla	
  rutrum	
  erat	
  id	
  neque	
  suscipit	
  eu	
  ultricies	
  odio	
  sollicitudin.	
  
         Aliquam	
  a	
  mi	
  vel	
  eros	
  placerat	
  hendrerit.	
  Phasellus	
  por6tor,	
  augue	
  sit	
  
         amet	
  vulputate	
  venena;s,	
  dui	
  leo	
  commodo	
  odio,	
  a	
  euismod	
  turpis	
  
         ligula	
  in	
  elit.	
  	
  


                                                                                                                    slot
{% extends "HelloBundle::layout" %}

{% block content %}
    Hello {{ name }}!
{% endblock %}
<html>
    <head>
        <title>
            {% block title %}{% endblock %}
        </title>
    </head>
    <body>
        {% block body %}{% endblock %}
    </body>
</html>
~ PAC / HMVC




http://en.wikipedia.org/wiki/Presentation-abstraction-control
Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  consectetur	
                 Lorem	
  ipsum	
  dolor	
  sit	
  
layout   adipiscing	
  elit.	
  In	
  vel	
  nulla	
  arcu,	
  vitae	
            amet,	
  consectetur	
  
         cursus	
  nunc.	
  Integer	
  semper	
  turpis	
  et	
  enim	
           adipiscing	
  elit.	
  In	
  vel	
  nulla	
  
         por6tor	
  iaculis.	
  Nulla	
  facilisi.	
  Lorem	
  ipsum	
            arcu,	
  vitae	
  cursus	
  nunc.	
  
         dolor	
  sit	
  amet,	
  consectetur	
  adipiscing	
  elit.	
            Integer	
  semper	
  turpis	
  et	
  
         Mauris	
  vehicula	
  ves;bulum	
  dictum.	
                             enim	
  por6tor	
  iaculis.	
  
         Aenean	
  non	
  velit	
  tortor.	
  Nullam	
  adipiscing	
              Nulla	
  facilisi.	
  Lorem	
  ipsum	
  
         malesuada	
  aliquam.	
  Mauris	
  dignissim,	
  urna	
                  dolor	
  sit	
  amet,	
  
         quis	
  iaculis	
  tempus,	
  justo	
  libero	
  por6tor	
               consectetur	
  adipiscing	
  elit.	
  
         est,	
  nec	
  eleifend	
  est	
  elit	
  vitae	
  ante.	
               Mauris	
  vehicula	
  
         Curabitur	
  interdum	
  luctus	
  metus,	
  in	
                        ves;bulum	
  dictum.	
  
         pulvinar	
  lectus	
  rutrum	
  sit	
  amet.	
  Duis	
                   Aenean	
  non	
  velit	
  tortor.	
  
         gravida,	
  metus	
  in	
  dictum	
  eleifend,	
  dolor	
                Nullam	
  adipiscing	
  
         risus	
  ;ncidunt	
  ligula,	
  non	
  volutpat	
  nulla	
               malesuada	
  aliquam.	
  
         sapien	
  imain controller
                       n	
  elit.	
  Nulla	
  rutrum	
  erat	
  id	
  neque	
               embedded MVC
                                                                                  Mauris	
  dignissim,	
  urna	
  
         suscipit	
  eu	
  ultricies	
  odio	
  sollicitudin.	
  
                       (_content slot)                                            quis	
  iaculis	
  tempus,	
  justo	
  
                                                                                                   controller
         Aliquam	
  a	
  mi	
  vel	
  eros	
  placerat	
  hendrerit.	
            libero	
  por6tor	
  est,	
  nec	
  
         Phasellus	
  por6tor,	
  augue	
  sit	
  amet	
                          eleifend	
  est	
  elit	
  vitae	
  ante.	
  
         vulputate	
  venena;s,	
  dui	
  leo	
  commodo	
                        Curabitur	
  interdum	
  luctus	
  
         odio,	
  a	
  euismod	
  turpis	
  ligula	
  in	
  elit.	
  	
           metus.	
  
public function indexAction($name)
{
    $embedded = $this['controller_resolver']
        ->render('HelloBundle:Hello:foo',
            array('name' => $name));

    return $this->render(
        'HelloBundle:Hello:index',
        array(
            'name' => $name,
            'embedded' => $embedded,
        )
    );
}
<?php $view->extend('...:layout') ?>

Lorem ipsum...

<?php echo $view['actions']
    ->render('HelloBundle:Hello:foo',
    array('name' => $name)) ?>

Lorem ipsum...
Bundles
.../
  SomeBundle/
     Controller/
     Entity/
     Resources/
       config/
       views/
     SomeBundle.php
     Tests/
public function registerBundleDirs()
{
    return array(
        'Application'    => __DIR__.'/../src/Application',
        'Bundle'         => __DIR__.'/../src/Bundle',
        'SymfonyBundle' => __DIR__.'/../src/vendor/
symfony/src/Symfony/Bundle',
    );
}
$this->render('SomeBundle:Hello:index', $params)
hello:
  pattern: /hello/:name
  defaults:
    { _controller: SomeBundle:Hello:index }
SomeBundle can be any of


ApplicationSomeBundle
BundleSomeBundle
SymfonyBundleSomeBundle
Environments
Developers     Customer     End Users




Development     Staging      Production
Environment   Environment   Environment
cache         cache          cache

  debug	
       debug	
        debug	
  

   logs	
        logs	
         logs	
  

    stats        stats          stats



Development     Staging      Production
Environment   Environment   Environment
# config/config.yml
doctrine.dbal:
    dbname:    mydbname
    user:      root
    password: %doctrine.dbal_password%

swift.mailer:
    transport:   smtp
    host:        localhost
# config/config_dev.yml
imports:
    - { resource: config.yml }

doctrine.dbal:
    password: null

swift.mailer:
    transport:   gmail
    username:    xxxxxxxx
    password:    xxxxxxxx
# Doctrine Configuration
doctrine.dbal:
    dbname:    xxxxxxxx
    user:      xxxxxxxx
    password: ~

# Swiftmailer Configuration
swift.mailer:
    transport: smtp
    encryption: ssl
    auth_mode: login
    host:       smtp.gmail.com
    username:   xxxxxxxx
    password:   xxxxxxxx
<!-- Doctrine Configuration -->
<doctrine:dbal dbname="xxxxxxxx" user="xxxxxxxx"
password="" />

<!-- Swiftmailer Configuration -->
<swift:mailer
    transport="smtp"
    encryption="ssl"
    auth_mode="login"
    host="smtp.gmail.com"
    username="xxxxxxxx"
    password="xxxxxxxx" />
// Doctrine Configuration
$container->loadFromExtension('doctrine', 'dbal', array(
    'dbname'   => 'xxxxxxxx',
    'user'     => 'xxxxxxxx',
    'password' => '',
));

// Swiftmailer Configuration
$container->loadFromExtension('swift', 'mailer', array(
    'transport' => "smtp",
    'encryption' => "ssl",
    'auth_mode' => "login",
    'host'       => "smtp.gmail.com",
    'username'   => "xxxxxxxx",
    'password'   => "xxxxxxxx",
));
Dependency Injection Container
Third-party libraries integration
     Unified Configuration
# Twig Configuration
twig.config:
    auto_reload: true

# Zend Logger Configuration
zend.logger:
    priority: debug
    path:     %kernel.root_dir%/logs/
%kernel.environment%.log
Configuration formats
XML, YAML, PHP, INI, or Annotations
   Parameters management
         Fast (cached)
          Inheritance
     Sensitive data security
               …
<doctrine:dbal
   dbname="sfweb"
   username="root"
   password="SuperSecretPasswordThatAnyoneCanSee"
/>
in a .htaccess or httpd.conf file
SetEnv SYMFONY__DOCTRINE__DBAL__PASSWORD "foobar"
                        %doctrine.dbal.password%
<doctrine:dbal
   dbname="sfweb"
   username="root"
   password="%doctrine.dbal.password%"
/>
Developer Tools
INFO: Matched route "blog_home" (parameters: array ( '_bundle' =>
'BlogBundle', '_controller' => 'Post', '_action' => 'index', '_route' =>
'blog_home',))

INFO: Using controller "BundleBlogBundleController
PostController::indexAction"

INFO: SELECT s0_.id AS id0, s0_.title AS title1, s0_.html_body AS html_body2,
s0_.excerpt AS excerpt3, s0_.published_at AS published_at4 FROM sf_weblog_post
s0_ ORDER BY s0_.published_at DESC LIMIT 10 (array ())
INFO: Matched route "blog_post" (parameters: array ( '_bundle' =>
'BlogBundle', '_controller' => 'Post', '_action' => 'show', '_format' =>
'html', 'id' => '3456', '_route' => 'blog_post',))

INFO: Using controller "BundleBlogBundleController
PostController::showAction »

INFO: SELECT s0_.id AS id0, s0_.title AS title1, s0_.html_body AS html_body2,
s0_.excerpt AS excerpt3, s0_.published_at AS published_at4 FROM sf_weblog_post
s0_ WHERE s0_.id = ? (array ( 0 => '3456',))
ERR: Post "3456" not found! (No result was found for query although at least
one row was expected.) (uncaught SymfonyComponentsRequestHandlerException
NotFoundHttpException exception)

INFO: Using controller "SymfonyFrameworkWebBundleController
ExceptionController::exceptionAction"
DEBUG: Notifying (until) event "core.request" to listener "(SymfonyFrameworkWebBundleListenerRequestParser, resolve)"
INFO: Matched route "blog_post" (parameters: array ( '_bundle' => 'BlogBundle', '_controller' => 'Post', '_action' => 'show',
'_format' => 'html', 'id' => '3456', '_route' => 'blog_post',))
DEBUG: Notifying (until) event "core.load_controller" to listener "(SymfonyFrameworkWebBundleListenerControllerLoader,
resolve)"
INFO: Using controller "BundleBlogBundleControllerPostController::showAction"
DEBUG: Listener "(SymfonyFrameworkWebBundleListenerControllerLoader, resolve)" processed the event "core.load_controller"
INFO: Trying to get post "3456" from database
INFO: SELECT s0_.id AS id0, s0_.title AS title1, s0_.html_body AS html_body2, s0_.excerpt AS excerpt3, s0_.published_at AS
published_at4 FROM sf_weblog_post s0_ WHERE s0_.id = ? (array ( 0 => '3456',))
DEBUG: Notifying (until) event "core.exception" to listener "(SymfonyFrameworkWebBundleListenerExceptionHandler, handle)"
ERR: Post "3456" not found! (No result was found for query although at least one row was expected.) (uncaught SymfonyComponents
RequestHandlerExceptionNotFoundHttpException exception)
DEBUG: Notifying (until) event "core.request" to listener "(SymfonyFrameworkWebBundleListenerRequestParser, resolve)"
DEBUG: Notifying (until) event "core.load_controller" to listener "(SymfonyFrameworkWebBundleListenerControllerLoader,
resolve)"
INFO: Using controller "SymfonyFrameworkWebBundleControllerExceptionController::exceptionAction"
DEBUG: Listener "(SymfonyFrameworkWebBundleListenerControllerLoader, resolve)" processed the event "core.load_controller"
DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleListenerResponseFilter, filter)"
DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleDebugDataCollector
DataCollectorManager, handle)"
DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleDebugWebDebugToolbar, handle)"
DEBUG: Listener "(SymfonyFrameworkWebBundleListenerExceptionHandler, handle)" processed the event "core.exception"
DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleListenerResponseFilter, filter)"
DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleDebugDataCollector
DataCollectorManager, handle)"
DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleDebugWebDebugToolbar, handle)"
Security

XSS / CSRF / SQL Injection
Functional Tests
$client = $this->createClient();

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

$this->assertTrue($crawler->filter(
  'html:contains("Hello Fabien")')->count());
$this->assertEquals(
  10,
  $crawler->filter('div.hentry')->count());

$this->assertTrue(
  $client->getResponse()->isSuccessful());
$crawler = $client->request(
    'GET', 'hello/Lucas'
);
$link = $crawler->selectLink("Greet Lucas");

$client->click($link);
$form = $crawler->selectButton('submit');

$client->submit($form, array(
    'name'         => 'Lucas',
    'country'      => 'France',
    'like_symfony' => true,
    'photo'        => '/path/to/lucas.jpg',
));
$harry = $this->createClient();
$sally = $this->createClient();

$harry->request('POST', '/say/sally/Hello');
$sally->request('GET', '/messages');

$this->assertEquals(201,
  $harry->getResponse()->getStatusCode());

$this->assertRegExp('/Hello/',
  $sally->getResponse()->getContent());
$harry = $this->createClient();
$sally = $this->createClient();

$harry->insulate();
$sally->insulate();

$harry->request('POST', '/say/sally/Hello');
$sally->request('GET', '/messages');

$this->assertEquals(201,
  $harry->getResponse()->getStatusCode());
$this->assertRegExp('/Hello/',
  $sally->getResponse()->getContent());
Caching
HTTP Expiration / HTTP Validation
$response->setSharedMaxAge(...);
$response->setTtl(...);
$response->setMaxAge(...);
$response->setClientTtl(...);
$response->setExpires(...);

$response->setETag(...);
$response->setLastModified(...);
Cache-Control: s-maxage=10
public function showAction()
{
  // ...

    $response = $this->render('...', $vars);

    $response->setSharedMaxAge(10);

    return $response;
}
Symfony 2 comes built-in with an HTTP accelerator
cacheable for 10 seconds
                                                                            cacheable for 5 seconds
         Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  consectetur	
           Lorem	
  ipsum	
  dolor	
  sit	
  
layout   adipiscing	
  elit.	
  In	
  vel	
  nulla	
  arcu,	
  vitae	
      amet,	
  consectetur	
  
         cursus	
  nunc.	
  Integer	
  semper	
  turpis	
  et	
  enim	
     adipiscing	
  elit.	
  In	
  vel	
  nulla	
  
         por6tor	
  iaculis.	
  Nulla	
  facilisi.	
  Lorem	
  ipsum	
      arcu,	
  vitae	
  cursus	
  nunc.	
  
         dolor	
  sit	
  amet,	
  consectetur	
  adipiscing	
  elit.	
      Integer	
  semper	
  turpis	
  et	
  
         Mauris	
  vehicula	
  ves;bulum	
  dictum.	
                       enim	
  por6tor	
  iaculis.	
  
         Aenean	
  non	
  velit	
  tortor.	
  Nullam	
  adipiscing	
        Nulla	
  facilisi.	
  Lorem	
  ipsum	
  
         malesuada	
  aliquam.	
  Mauris	
  dignissim,	
  urna	
            dolor	
  sit	
  amet,	
  
         quis	
  iaculis	
  tempus,	
  justo	
  libero	
  por6tor	
         consectetur	
  adipiscing	
  elit.	
  
         est,	
  nec	
  eleifend	
  est	
  elit	
  vitae	
  ante.	
         Mauris	
  vehicula	
  
         Curabitur	
  interdum	
  luctus	
  metus,	
  in	
                  ves;bulum	
  dictum.	
  
         pulvinar	
  lectus	
  rutrum	
  sit	
  amet.	
  Duis	
             Aenean	
  non	
  velit	
  tortor.	
  
         gravida,	
  metus	
  in	
  dictum	
  eleifend,	
  dolor	
          Nullam	
  adipiscing	
  
         risus	
  ;ncidunt	
  ligula,	
  non	
  volutpat	
  nulla	
         malesuada	
  aliquam.	
  
         sapien	
  main Nulla	
  rutrum	
  erat	
  id	
  neque	
  
                     in	
  elit.	
                                          Mauris	
  embeddedurna	
  
                                                                                       dignissim,	
  
         suscipit	
  eu	
  ultricies	
  odio	
  sollicitudin.	
  
                 controller                                                 quis	
  iaculis	
  tempus,	
  justo	
  
                                                                                        controller
         Aliquam	
  a	
  mi	
  vel	
  eros	
  placerat	
  hendrerit.	
      libero	
  por6tor	
  est,	
  nec	
  
         Phasellus	
  por6tor,	
  augue	
  sit	
  amet	
                    eleifend	
  est	
  elit	
  vitae	
  ante.	
  
         vulputate	
  venena;s,	
  dui	
  leo	
  commodo	
                  Curabitur	
  interdum	
  luctus	
  
         odio,	
  a	
  euismod	
  turpis	
  ligula	
  in	
  elit.	
  	
     metus.	
  
cacheable for 10 seconds

<?php $view->extend('...:layout') ?>

<?php $view['slots']->start('sidebar') ?> 5 seconds
                                 cacheable for
<?php echo $view['actions']->render('...:foo') ?>

<?php $view['slots']->stop() ?>
$view['actions']->render('HelloBundle:Hello:foo',
    array('name' => $name),
    array('standalone' => true)
)
Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  consectetur	
              Lorem	
  ipsum	
  dolor	
  sit	
  
adipiscing	
  elit.	
  In	
  vel	
  nulla	
  arcu,	
  vitae	
         amet,	
  consectetur	
  
cursus	
  nunc.	
  Integer	
  semper	
  turpis	
  et	
  enim	
        adipiscing	
  elit.	
  In	
  vel	
  nulla	
  
por6tor	
  iaculis.	
  Nulla	
  facilisi.	
  Lorem	
  ipsum	
         arcu,	
  vitae	
  cursus	
  nunc.	
  
dolor	
  sit	
  amet,	
  consectetur	
  adipiscing	
  elit.	
         Integer	
  semper	
  turpis	
  et	
  
Mauris	
  vehicula	
  ves;bulum	
  dictum.	
                          enim	
  por6tor	
  iaculis.	
  
Aenean	
  non	
  velit	
  tortor.	
  Nullam	
  adipiscing	
           Nulla	
  facilisi.	
  Lorem	
  ipsum	
  
malesuada	
  aliquam.	
  Mauris	
  dignissim,	
  urna	
               dolor	
  sit	
  amet,	
  
quis	
  iaculis	
  tempus,	
  justo	
  libero	
  por6tor	
            consectetur	
  adipiscing	
  elit.	
  
est,	
  nec	
  eleifend	
  est	
  elit	
  vitae	
  ante.	
            Mauris	
  vehicula	
  
Curabitur	
  interdum	
  luctus	
  metus,	
  in	
                     ves;bulum	
  dictum.	
  
pulvinar	
  lectus	
  rutrum	
  sit	
  amet.	
  Duis	
                Aenean	
  non	
  velit	
  tortor.	
  
gravida,	
  metus	
  in	
  dictum	
  eleifend,	
  dolor	
             Nullam	
  adipiscing	
  
risus	
  ;ncidunt	
  ligula,	
  non	
  volutpat	
  nulla	
            malesuada	
  aliquam.	
  
sapien	
  in	
  elit.	
  Nulla	
  rutrum	
  erat	
  id	
  neque	
     Mauris	
  dignissim,	
  urna	
  
suscipit	
  eu	
  ultricies	
  odio	
  sollicitudin.	
                quis	
  iaculis	
  tempus,	
  justo	
  
Aliquam	
  a	
  mi	
  vel	
  eros	
  placerat	
  hendrerit.	
         libero	
  por6tor	
  est,	
  nec	
  
Phasellus	
  por6tor,	
  augue	
  sit	
  amet	
                       eleifend	
  est	
  elit	
  vitae	
  ante.	
  
vulputate	
  venena;s,	
  dui	
  leo	
  commodo	
                     Curabitur	
  interdum	
  luctus	
  
odio,	
  a	
  euismod	
  turpis	
  ligula	
  in	
  elit.	
  	
        metus.	
  
<esi:include src="..." />
Lorem	
  ipsum	
  dolor	
  sit	
  amet,	
  consectetur	
  
adipiscing	
  elit.	
  In	
  vel	
  nulla	
  arcu,	
  vitae	
  
cursus	
  nunc.	
  Integer	
  semper	
  turpis	
  et	
  enim	
  
por6tor	
  iaculis.	
  Nulla	
  facilisi.	
  Lorem	
  ipsum	
  
dolor	
  sit	
  amet,	
  consectetur	
  adipiscing	
  elit.	
  
Mauris	
  vehicula	
  ves;bulum	
  dictum.	
  
Aenean	
  non	
  velit	
  tortor.	
  Nullam	
  adipiscing	
  
malesuada	
  aliquam.	
  Mauris	
  dignissim,	
  urna	
  
quis	
  iaculis	
  tempus,	
  justo	
  libero	
  por6tor	
  
est,	
  nec	
  eleifend	
  est	
  elit	
  vitae	
  ante.	
  
Curabitur	
  interdum	
  luctus	
  metus,	
  in	
  
pulvinar	
  lectus	
  rutrum	
  sit	
  amet.	
  Duis	
  
gravida,	
  metus	
  in	
  dictum	
  eleifend,	
  dolor	
  
risus	
  ;ncidunt	
  ligula,	
  non	
  volutpat	
  nulla	
  
sapien	
  in	
  elit.	
  Nulla	
  rutrum	
  erat	
  id	
  neque	
  
suscipit	
  eu	
  ultricies	
  odio	
  sollicitudin.	
  
Aliquam	
  a	
  mi	
  vel	
  eros	
  placerat	
  hendrerit.	
  
Phasellus	
  por6tor,	
  augue	
  sit	
  amet	
  
vulputate	
  venena;s,	
  dui	
  leo	
  commodo	
  
odio,	
  a	
  euismod	
  turpis	
  ligula	
  in	
  elit.	
  	
  
ESI… or Edge Side Includes
Lorem	
  ipsum	
  
                                                                      dolor	
  sit	
  
                                                                      amet,	
  	
  

         1
                                                                  2




                                                                                                       Symfony2 Application
                                                                                           Lorem	
  
                                                                                           ipsum	
  




                                                  Reverse Proxy
                                                                                           dolor	
  
Client




                                                                  3


             Lorem	
  ipsum	
     Lorem	
  
             dolor	
  sit	
       ipsum	
  
             amet,	
  	
          dolor	
  



                                              4
Web Server




                      Symfony2
                        app
Requests




           Response
Web Server

               Symfony2 HTTP proxy


                      Symfony2
                        app
Requests




           Response
Reverse proxy

                      Web Server




                      Symfony2
                        app
Requests




           Response
Extensibility
Request


      core.request


           getController()


      core.controller


           getArguments()


      core.view


      core.response



Response
Request


      core.request


           getController()


      core.controller
                             core.exception

           getArguments()


      core.view


      core.response



Response
SwiftmailerBundle     DoctrineBundle


                                 ZendBundle               ...


             FrameworkBundle     TwigBundle

Bundles

Components
               HttpKernel      DependencyInjection      Console


                                    Routing           Templating


             HttpFoundation    Event Dispatcher           ...
Questions?

More Related Content

What's hot

Dependency Injection IPC 201
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201Fabien 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
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony TechniquesKris Wallsmith
 
Dependency Injection with PHP 5.3
Dependency Injection with PHP 5.3Dependency Injection with PHP 5.3
Dependency Injection with PHP 5.3Fabien Potencier
 
Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Fabien Potencier
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Kris Wallsmith
 
The Origin of Lithium
The Origin of LithiumThe Origin of Lithium
The Origin of LithiumNate Abele
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Kris Wallsmith
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of LithiumNate Abele
 
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Fabien Potencier
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksNate Abele
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium AppsNate Abele
 
PHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php frameworkPHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php frameworkG Woo
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8PrinceGuru MS
 
Symfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteSymfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteLeonardo Proietti
 
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo EditionLithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo EditionNate Abele
 
Php tips-and-tricks4128
Php tips-and-tricks4128Php tips-and-tricks4128
Php tips-and-tricks4128PrinceGuru MS
 

What's hot (20)

Dependency Injection IPC 201
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201
 
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
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
Dependency Injection with PHP 5.3
Dependency Injection with PHP 5.3Dependency Injection with PHP 5.3
Dependency Injection with PHP 5.3
 
Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Dependency injection-zendcon-2010
Dependency injection-zendcon-2010
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
 
The Origin of Lithium
The Origin of LithiumThe Origin of Lithium
The Origin of Lithium
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
 
New in php 7
New in php 7New in php 7
New in php 7
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
 
PHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php frameworkPHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php framework
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8
 
Symfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteSymfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il cliente
 
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo EditionLithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
 
Php tips-and-tricks4128
Php tips-and-tricks4128Php tips-and-tricks4128
Php tips-and-tricks4128
 

Similar to Symfony2 - WebExpo 2010

関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5Wim Godden
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHPNat Weerawan
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207patter
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Jacopo Romei
 
PHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source ProjectPHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source Projectxsist10
 
Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12Jakub Zalas
 
Filesystem abstractions and msg queue sergeev - symfony camp 2018
Filesystem abstractions and msg queue   sergeev - symfony camp 2018Filesystem abstractions and msg queue   sergeev - symfony camp 2018
Filesystem abstractions and msg queue sergeev - symfony camp 2018Юлия Коваленко
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers StealBen Scofield
 
Symfony internals [english]
Symfony internals [english]Symfony internals [english]
Symfony internals [english]Raul Fraile
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
Tobias Nyholm "Deep dive into Symfony 4 internals"
Tobias Nyholm "Deep dive into Symfony 4 internals"Tobias Nyholm "Deep dive into Symfony 4 internals"
Tobias Nyholm "Deep dive into Symfony 4 internals"Fwdays
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Hugo Hamon
 
The symfony platform: Create your very own framework (PHP Quebec 2008)
The symfony platform: Create your very own framework (PHP Quebec 2008)The symfony platform: Create your very own framework (PHP Quebec 2008)
The symfony platform: Create your very own framework (PHP Quebec 2008)Fabien Potencier
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkDirk Haun
 
TYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase frameworkTYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase frameworkChristian Trabold
 

Similar to Symfony2 - WebExpo 2010 (20)

関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011
 
Symfony2 revealed
Symfony2 revealedSymfony2 revealed
Symfony2 revealed
 
PHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source ProjectPHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source Project
 
Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12
 
Filesystem abstractions and msg queue sergeev - symfony camp 2018
Filesystem abstractions and msg queue   sergeev - symfony camp 2018Filesystem abstractions and msg queue   sergeev - symfony camp 2018
Filesystem abstractions and msg queue sergeev - symfony camp 2018
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers Steal
 
Symfony internals [english]
Symfony internals [english]Symfony internals [english]
Symfony internals [english]
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Tobias Nyholm "Deep dive into Symfony 4 internals"
Tobias Nyholm "Deep dive into Symfony 4 internals"Tobias Nyholm "Deep dive into Symfony 4 internals"
Tobias Nyholm "Deep dive into Symfony 4 internals"
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
CakePHP workshop
CakePHP workshopCakePHP workshop
CakePHP workshop
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
The symfony platform: Create your very own framework (PHP Quebec 2008)
The symfony platform: Create your very own framework (PHP Quebec 2008)The symfony platform: Create your very own framework (PHP Quebec 2008)
The symfony platform: Create your very own framework (PHP Quebec 2008)
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
TYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase frameworkTYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase framework
 

More from Fabien Potencier

Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Fabien 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
 
Dependency Injection - ConFoo 2010
Dependency Injection - ConFoo 2010Dependency Injection - ConFoo 2010
Dependency Injection - ConFoo 2010Fabien Potencier
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Fabien Potencier
 
Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3Fabien Potencier
 
Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Fabien Potencier
 
Symfony And Zend Framework Together 2009
Symfony And Zend Framework Together 2009Symfony And Zend Framework Together 2009
Symfony And Zend Framework Together 2009Fabien Potencier
 
Twig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHPTwig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHPFabien Potencier
 
symfony: Un Framework Open-Source pour les Entreprises (Solutions Linux 2008)
symfony: Un Framework Open-Source pour les Entreprises (Solutions Linux 2008)symfony: Un Framework Open-Source pour les Entreprises (Solutions Linux 2008)
symfony: Un Framework Open-Source pour les Entreprises (Solutions Linux 2008)Fabien Potencier
 

More from Fabien Potencier (16)

Varnish
VarnishVarnish
Varnish
 
Look beyond PHP
Look beyond PHPLook beyond PHP
Look beyond PHP
 
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
 
Caching on the Edge with Symfony2
Caching on the Edge with Symfony2Caching on the Edge with Symfony2
Caching on the Edge with Symfony2
 
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
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3
 
Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3
 
Playing With PHP 5.3
Playing With PHP 5.3Playing With PHP 5.3
Playing With PHP 5.3
 
Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009
 
Symfony And Zend Framework Together 2009
Symfony And Zend Framework Together 2009Symfony And Zend Framework Together 2009
Symfony And Zend Framework Together 2009
 
Twig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHPTwig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHP
 
symfony: Un Framework Open-Source pour les Entreprises (Solutions Linux 2008)
symfony: Un Framework Open-Source pour les Entreprises (Solutions Linux 2008)symfony: Un Framework Open-Source pour les Entreprises (Solutions Linux 2008)
symfony: Un Framework Open-Source pour les Entreprises (Solutions Linux 2008)
 

Recently uploaded

Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
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
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
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
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 

Recently uploaded (20)

Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
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...
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
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
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 

Symfony2 - WebExpo 2010

  • 2. How many of you have already used symfony1?
  • 3. How many of you have already played with Symfony2?
  • 5. A set of decoupled and cohesive components
  • 6. DependencyInjection EventDispatcher HttpFoundation OutputEscaper DomCrawler CssSelector Templating HttpKernel BrowserKit Validator Routing Console Process Finder Form Yaml
  • 8. A set of decoupled and cohesive components Autoloading
  • 9. PEAR_Log > PEAR/Log.php Zend_Log > Zend/Log.php Swift_Mime_Message > Swift/Mime/Message.php Twig_Node_For > Twig/Node/For.php
  • 10. SymfonyFoundationKernel Symfony/Foundation/Kernel.php DoctrineDBALDriver Doctrine/DBAL/Driver.php pdependreflectionReflectionSession pdepend/reflection/ReflectionSession.php http://groups.google.com/group/php-standards/web/psr-0-final-proposal  
  • 12. $loader->registerNamespaces(array( 'Symfony' => '/path/to/symfony/src', 'Doctrine' => '/path/to/doctrine/lib', 'pdepend' => '/path/to/reflection/source', )); PHP 5.3 technical interoperability standards
  • 13. $loader->registerPrefixes(array( 'Swift_' => '/path/to/swiftmailer/lib/classes', 'Zend_' => '/path/to/vendor/zend/library', )); PEAR style
  • 14. A set of decoupled and cohesive components Process
  • 15. use SymfonyComponentProcessProcess; $cmd = 'ssh 1.2.3.4 "ps waux"'; $process = new Process($cmd); $process->run(); if (!$process->isSuccessful()) { throw new RuntimeException( $process->getErrorOutput()); } echo $process->getOutput();
  • 16. $cmd = 'ssh 1.2.3.4 "tail -f /some/log"'; $process = new Process($cmd); $process->run(function ($type, $buffer) { echo $buffer; });
  • 17. use SymfonyComponentProcessPhpProcess; $process = new PhpProcess( '<?php echo "hello"; ?>'); $process->run(); if (!$process->isSuccessful()) { throw new RuntimeException( $process->getErrorOutput()); } echo $process->getOutput();
  • 18. A set of decoupled and cohesive components CssSelector
  • 20. use SymfonyComponentCssSelectorParser; $document = new DOMDocument(); $document->loadHTMLFile('...'); $xpath = new DOMXPath($document); $expr = Parser::cssToXpath('a.smart'); $nodes = $xpath->query($expr); foreach ($nodes as $node) { printf("%s (%s)n", $node->nodeValue, $node- >getAttribute('href')); }
  • 21. A set of decoupled and cohesive components Finder
  • 22. use SymfonyComponentFinderFinder; $finder = new Finder(); $finder ->files() ->in(__DIR__) ->...() ->sortByName() ;
  • 23. $finder ->name('*.php') ->depth('<= 1') ->date('>= yesterday') ->size('<= 1K') ->filter(function (SplFileInfo $file) { return strlen($file->getBasename()) < 9; }) ;
  • 24. foreach ($finder as $file) { print $file->getRealpath()."n"; } $files = iterator_to_array($finder); $count = iterator_count($finder);
  • 25. use SymfonyComponentFinderFinder; $s3 = new Zend_Service_Amazon_S3($key, $sct); $s3->registerStreamWrapper("s3"); $finder = new Finder(); $finder ->name('photos*') ->size('< 100K') ->date('since 1 hour ago') ->in('s3://bucket-name') ;
  • 26. A set of decoupled and cohesive components Routing
  • 32. post: pattern: /blog/:year/:month/:day/:slug defaults: { _controller: BlogBundle:Post:show }
  • 33. <routes> <route id="post" pattern="/blog/:year/:month/:day/:slug"> <default key="_controller"> BlogBundle:Post:show </default> </route> </routes>
  • 34. use SymfonyComponentRoutingRouteCollection; use SymfonyComponentRoutingRoute; $collection = new RouteCollection(); $route = new Route( '/blog/:year/:month/:day/:slug', array('_controller' => 'BlogBundle:Post:show')); $collection->addRoute('post', $route); return $collection;
  • 35. $router ->match('/blog/2010/09/18/Symfony2-in-India') $router ->generate('post', array('slug' => '...'))
  • 36. post: pattern: /post/:slug defaults: { _controller: BlogBundle:Post:show }
  • 37. $router ->generate('post', array('slug' => '...'))
  • 39. An Object-Oriented abstraction on top of PHP Request
  • 40. use SymfonyComponentHttpFoundationRequest; $request = new Request(); // get a $_GET parameter $request->query->get('page'); // get a $_POST parameter $request->request->get('page'); // get a $_COOKIE parameter $request->cookies->get('name'); $request->getPreferredLanguage(array('en', 'fr')); $request->isXmlHttpRequest();
  • 41. // get a $_FILE parameter $f = $request->files->get('image'); // $f is an instance of // SymfonyComponentHttpFoundationFileUploadedFile // guess extension, based on the mime type $n = '/path/to/file'.$file->getDefaultExtension(); $f->move($n);
  • 42. new Request(); new Request( $_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER ); Request::create('/hello/Fabien', 'GET');
  • 43. An Object-Oriented abstraction on top of PHP Session
  • 44. $session = $request->getSession(); $session->set('foo', 'bar'); $session->get('foo'); $session->setFlash('notice', 'Congratulations!');
  • 45. An Object-Oriented abstraction on top of PHP Response
  • 46. use SymfonyComponentHttpFoundationResponse; $response = new Response('Hello World', 200, array('Content-Type' => 'text/plain')); $response->send(); $response->setHeader('Content-Type', 'text/ plain'); $response->setCookie('foo', 'bar'); $response->setContent('Hello World'); $response->setStatusCode(200);
  • 47. An Object-Oriented abstraction of the HTTP dialog
  • 48. A MVC Web Framework
  • 49. The Symfony2 MVC Philosophy
  • 50. Be as easy as possible for newcomers and as flexible as possible for advanced users
  • 51. MVC
  • 53. post: pattern: /hello/:name defaults: { _controller: HelloBundle:Hello:index } namespace ApplicationHelloBundleController; use SymfonyBundleFrameworkBundleController; class HelloController extends Controller { public function indexAction($name) { return new Response('Hello '.$name); } }
  • 54. namespace ApplicationHelloBundleController; use SymfonyBundleFrameworkBundleController; class HelloController extends Controller { public function indexAction($name) { // Get things from the Model return $this->render( 'HelloBundle:Hello:index', array('name' => $name) ); } }
  • 55. Hello <?php echo $name ?>!
  • 57. <html> <head> <title> <?php $view['slots']->output('title') ?> </title> </head> <body> <?php $view['slots']->output('_content') ?> </body> </html>
  • 58. slot title Lorem  ipsum  dolor  sit  amet,  consectetur  adipiscing  elit.  In  vel   _content Lorem  ipsum  dolor  sit  amet,  consectetur  adipiscing  elit.  In  vel  nulla  arcu,   vitae  cursus  nunc.  Integer  semper  turpis  et  enim  por6tor  iaculis.  Nulla   facilisi.  Lorem  ipsum  dolor  sit  amet,  consectetur  adipiscing  elit.  Mauris   vehicula  ves;bulum  dictum.  Aenean  non  velit  tortor.  Nullam  adipiscing   malesuada  aliquam.  Mauris  dignissim,  urna  quis  iaculis  tempus,  justo   layout libero  por6tor  est,  nec  eleifend  est  elit  vitae  ante.  Curabitur  interdum   luctus  metus,  in  pulvinar  lectus  rutrum  sit  amet.  Duis  gravida,  metus  in   dictum  eleifend,  dolor  risus  ;ncidunt  ligula,  non  volutpat  nulla  sapien  in   elit.  Nulla  rutrum  erat  id  neque  suscipit  eu  ultricies  odio  sollicitudin.   Aliquam  a  mi  vel  eros  placerat  hendrerit.  Phasellus  por6tor,  augue  sit   amet  vulputate  venena;s,  dui  leo  commodo  odio,  a  euismod  turpis   ligula  in  elit.     slot
  • 59. {% extends "HelloBundle::layout" %} {% block content %} Hello {{ name }}! {% endblock %}
  • 60. <html> <head> <title> {% block title %}{% endblock %} </title> </head> <body> {% block body %}{% endblock %} </body> </html>
  • 61. ~ PAC / HMVC http://en.wikipedia.org/wiki/Presentation-abstraction-control
  • 62. Lorem  ipsum  dolor  sit  amet,  consectetur   Lorem  ipsum  dolor  sit   layout adipiscing  elit.  In  vel  nulla  arcu,  vitae   amet,  consectetur   cursus  nunc.  Integer  semper  turpis  et  enim   adipiscing  elit.  In  vel  nulla   por6tor  iaculis.  Nulla  facilisi.  Lorem  ipsum   arcu,  vitae  cursus  nunc.   dolor  sit  amet,  consectetur  adipiscing  elit.   Integer  semper  turpis  et   Mauris  vehicula  ves;bulum  dictum.   enim  por6tor  iaculis.   Aenean  non  velit  tortor.  Nullam  adipiscing   Nulla  facilisi.  Lorem  ipsum   malesuada  aliquam.  Mauris  dignissim,  urna   dolor  sit  amet,   quis  iaculis  tempus,  justo  libero  por6tor   consectetur  adipiscing  elit.   est,  nec  eleifend  est  elit  vitae  ante.   Mauris  vehicula   Curabitur  interdum  luctus  metus,  in   ves;bulum  dictum.   pulvinar  lectus  rutrum  sit  amet.  Duis   Aenean  non  velit  tortor.   gravida,  metus  in  dictum  eleifend,  dolor   Nullam  adipiscing   risus  ;ncidunt  ligula,  non  volutpat  nulla   malesuada  aliquam.   sapien  imain controller n  elit.  Nulla  rutrum  erat  id  neque   embedded MVC Mauris  dignissim,  urna   suscipit  eu  ultricies  odio  sollicitudin.   (_content slot) quis  iaculis  tempus,  justo   controller Aliquam  a  mi  vel  eros  placerat  hendrerit.   libero  por6tor  est,  nec   Phasellus  por6tor,  augue  sit  amet   eleifend  est  elit  vitae  ante.   vulputate  venena;s,  dui  leo  commodo   Curabitur  interdum  luctus   odio,  a  euismod  turpis  ligula  in  elit.     metus.  
  • 63. public function indexAction($name) { $embedded = $this['controller_resolver'] ->render('HelloBundle:Hello:foo', array('name' => $name)); return $this->render( 'HelloBundle:Hello:index', array( 'name' => $name, 'embedded' => $embedded, ) ); }
  • 64. <?php $view->extend('...:layout') ?> Lorem ipsum... <?php echo $view['actions'] ->render('HelloBundle:Hello:foo', array('name' => $name)) ?> Lorem ipsum...
  • 66. .../ SomeBundle/ Controller/ Entity/ Resources/ config/ views/ SomeBundle.php Tests/
  • 67. public function registerBundleDirs() { return array( 'Application' => __DIR__.'/../src/Application', 'Bundle' => __DIR__.'/../src/Bundle', 'SymfonyBundle' => __DIR__.'/../src/vendor/ symfony/src/Symfony/Bundle', ); }
  • 69. hello: pattern: /hello/:name defaults: { _controller: SomeBundle:Hello:index }
  • 70. SomeBundle can be any of ApplicationSomeBundle BundleSomeBundle SymfonyBundleSomeBundle
  • 72. Developers Customer End Users Development Staging Production Environment Environment Environment
  • 73. cache cache cache debug   debug   debug   logs   logs   logs   stats stats stats Development Staging Production Environment Environment Environment
  • 74. # config/config.yml doctrine.dbal: dbname: mydbname user: root password: %doctrine.dbal_password% swift.mailer: transport: smtp host: localhost
  • 75. # config/config_dev.yml imports: - { resource: config.yml } doctrine.dbal: password: null swift.mailer: transport: gmail username: xxxxxxxx password: xxxxxxxx
  • 76. # Doctrine Configuration doctrine.dbal: dbname: xxxxxxxx user: xxxxxxxx password: ~ # Swiftmailer Configuration swift.mailer: transport: smtp encryption: ssl auth_mode: login host: smtp.gmail.com username: xxxxxxxx password: xxxxxxxx
  • 77. <!-- Doctrine Configuration --> <doctrine:dbal dbname="xxxxxxxx" user="xxxxxxxx" password="" /> <!-- Swiftmailer Configuration --> <swift:mailer transport="smtp" encryption="ssl" auth_mode="login" host="smtp.gmail.com" username="xxxxxxxx" password="xxxxxxxx" />
  • 78. // Doctrine Configuration $container->loadFromExtension('doctrine', 'dbal', array( 'dbname' => 'xxxxxxxx', 'user' => 'xxxxxxxx', 'password' => '', )); // Swiftmailer Configuration $container->loadFromExtension('swift', 'mailer', array( 'transport' => "smtp", 'encryption' => "ssl", 'auth_mode' => "login", 'host' => "smtp.gmail.com", 'username' => "xxxxxxxx", 'password' => "xxxxxxxx", ));
  • 80. Third-party libraries integration Unified Configuration
  • 81. # Twig Configuration twig.config: auto_reload: true # Zend Logger Configuration zend.logger: priority: debug path: %kernel.root_dir%/logs/ %kernel.environment%.log
  • 82. Configuration formats XML, YAML, PHP, INI, or Annotations Parameters management Fast (cached) Inheritance Sensitive data security …
  • 83. <doctrine:dbal dbname="sfweb" username="root" password="SuperSecretPasswordThatAnyoneCanSee" />
  • 84. in a .htaccess or httpd.conf file SetEnv SYMFONY__DOCTRINE__DBAL__PASSWORD "foobar" %doctrine.dbal.password%
  • 85. <doctrine:dbal dbname="sfweb" username="root" password="%doctrine.dbal.password%" />
  • 87. INFO: Matched route "blog_home" (parameters: array ( '_bundle' => 'BlogBundle', '_controller' => 'Post', '_action' => 'index', '_route' => 'blog_home',)) INFO: Using controller "BundleBlogBundleController PostController::indexAction" INFO: SELECT s0_.id AS id0, s0_.title AS title1, s0_.html_body AS html_body2, s0_.excerpt AS excerpt3, s0_.published_at AS published_at4 FROM sf_weblog_post s0_ ORDER BY s0_.published_at DESC LIMIT 10 (array ())
  • 88. INFO: Matched route "blog_post" (parameters: array ( '_bundle' => 'BlogBundle', '_controller' => 'Post', '_action' => 'show', '_format' => 'html', 'id' => '3456', '_route' => 'blog_post',)) INFO: Using controller "BundleBlogBundleController PostController::showAction » INFO: SELECT s0_.id AS id0, s0_.title AS title1, s0_.html_body AS html_body2, s0_.excerpt AS excerpt3, s0_.published_at AS published_at4 FROM sf_weblog_post s0_ WHERE s0_.id = ? (array ( 0 => '3456',)) ERR: Post "3456" not found! (No result was found for query although at least one row was expected.) (uncaught SymfonyComponentsRequestHandlerException NotFoundHttpException exception) INFO: Using controller "SymfonyFrameworkWebBundleController ExceptionController::exceptionAction"
  • 89. DEBUG: Notifying (until) event "core.request" to listener "(SymfonyFrameworkWebBundleListenerRequestParser, resolve)" INFO: Matched route "blog_post" (parameters: array ( '_bundle' => 'BlogBundle', '_controller' => 'Post', '_action' => 'show', '_format' => 'html', 'id' => '3456', '_route' => 'blog_post',)) DEBUG: Notifying (until) event "core.load_controller" to listener "(SymfonyFrameworkWebBundleListenerControllerLoader, resolve)" INFO: Using controller "BundleBlogBundleControllerPostController::showAction" DEBUG: Listener "(SymfonyFrameworkWebBundleListenerControllerLoader, resolve)" processed the event "core.load_controller" INFO: Trying to get post "3456" from database INFO: SELECT s0_.id AS id0, s0_.title AS title1, s0_.html_body AS html_body2, s0_.excerpt AS excerpt3, s0_.published_at AS published_at4 FROM sf_weblog_post s0_ WHERE s0_.id = ? (array ( 0 => '3456',)) DEBUG: Notifying (until) event "core.exception" to listener "(SymfonyFrameworkWebBundleListenerExceptionHandler, handle)" ERR: Post "3456" not found! (No result was found for query although at least one row was expected.) (uncaught SymfonyComponents RequestHandlerExceptionNotFoundHttpException exception) DEBUG: Notifying (until) event "core.request" to listener "(SymfonyFrameworkWebBundleListenerRequestParser, resolve)" DEBUG: Notifying (until) event "core.load_controller" to listener "(SymfonyFrameworkWebBundleListenerControllerLoader, resolve)" INFO: Using controller "SymfonyFrameworkWebBundleControllerExceptionController::exceptionAction" DEBUG: Listener "(SymfonyFrameworkWebBundleListenerControllerLoader, resolve)" processed the event "core.load_controller" DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleListenerResponseFilter, filter)" DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleDebugDataCollector DataCollectorManager, handle)" DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleDebugWebDebugToolbar, handle)" DEBUG: Listener "(SymfonyFrameworkWebBundleListenerExceptionHandler, handle)" processed the event "core.exception" DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleListenerResponseFilter, filter)" DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleDebugDataCollector DataCollectorManager, handle)" DEBUG: Notifying (filter) event "core.response" to listener "(SymfonyFrameworkWebBundleDebugWebDebugToolbar, handle)"
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98. Security XSS / CSRF / SQL Injection
  • 100. $client = $this->createClient(); $crawler = $client->request( 'GET', '/hello/Fabien'); $this->assertTrue($crawler->filter( 'html:contains("Hello Fabien")')->count());
  • 101. $this->assertEquals( 10, $crawler->filter('div.hentry')->count()); $this->assertTrue( $client->getResponse()->isSuccessful());
  • 102. $crawler = $client->request( 'GET', 'hello/Lucas' );
  • 103. $link = $crawler->selectLink("Greet Lucas"); $client->click($link);
  • 104. $form = $crawler->selectButton('submit'); $client->submit($form, array( 'name' => 'Lucas', 'country' => 'France', 'like_symfony' => true, 'photo' => '/path/to/lucas.jpg', ));
  • 105. $harry = $this->createClient(); $sally = $this->createClient(); $harry->request('POST', '/say/sally/Hello'); $sally->request('GET', '/messages'); $this->assertEquals(201, $harry->getResponse()->getStatusCode()); $this->assertRegExp('/Hello/', $sally->getResponse()->getContent());
  • 106. $harry = $this->createClient(); $sally = $this->createClient(); $harry->insulate(); $sally->insulate(); $harry->request('POST', '/say/sally/Hello'); $sally->request('GET', '/messages'); $this->assertEquals(201, $harry->getResponse()->getStatusCode()); $this->assertRegExp('/Hello/', $sally->getResponse()->getContent());
  • 108. HTTP Expiration / HTTP Validation
  • 111. public function showAction() { // ... $response = $this->render('...', $vars); $response->setSharedMaxAge(10); return $response; }
  • 112. Symfony 2 comes built-in with an HTTP accelerator
  • 113. cacheable for 10 seconds cacheable for 5 seconds Lorem  ipsum  dolor  sit  amet,  consectetur   Lorem  ipsum  dolor  sit   layout adipiscing  elit.  In  vel  nulla  arcu,  vitae   amet,  consectetur   cursus  nunc.  Integer  semper  turpis  et  enim   adipiscing  elit.  In  vel  nulla   por6tor  iaculis.  Nulla  facilisi.  Lorem  ipsum   arcu,  vitae  cursus  nunc.   dolor  sit  amet,  consectetur  adipiscing  elit.   Integer  semper  turpis  et   Mauris  vehicula  ves;bulum  dictum.   enim  por6tor  iaculis.   Aenean  non  velit  tortor.  Nullam  adipiscing   Nulla  facilisi.  Lorem  ipsum   malesuada  aliquam.  Mauris  dignissim,  urna   dolor  sit  amet,   quis  iaculis  tempus,  justo  libero  por6tor   consectetur  adipiscing  elit.   est,  nec  eleifend  est  elit  vitae  ante.   Mauris  vehicula   Curabitur  interdum  luctus  metus,  in   ves;bulum  dictum.   pulvinar  lectus  rutrum  sit  amet.  Duis   Aenean  non  velit  tortor.   gravida,  metus  in  dictum  eleifend,  dolor   Nullam  adipiscing   risus  ;ncidunt  ligula,  non  volutpat  nulla   malesuada  aliquam.   sapien  main Nulla  rutrum  erat  id  neque   in  elit.   Mauris  embeddedurna   dignissim,   suscipit  eu  ultricies  odio  sollicitudin.   controller quis  iaculis  tempus,  justo   controller Aliquam  a  mi  vel  eros  placerat  hendrerit.   libero  por6tor  est,  nec   Phasellus  por6tor,  augue  sit  amet   eleifend  est  elit  vitae  ante.   vulputate  venena;s,  dui  leo  commodo   Curabitur  interdum  luctus   odio,  a  euismod  turpis  ligula  in  elit.     metus.  
  • 114. cacheable for 10 seconds <?php $view->extend('...:layout') ?> <?php $view['slots']->start('sidebar') ?> 5 seconds cacheable for <?php echo $view['actions']->render('...:foo') ?> <?php $view['slots']->stop() ?>
  • 115. $view['actions']->render('HelloBundle:Hello:foo', array('name' => $name), array('standalone' => true) )
  • 116. Lorem  ipsum  dolor  sit  amet,  consectetur   Lorem  ipsum  dolor  sit   adipiscing  elit.  In  vel  nulla  arcu,  vitae   amet,  consectetur   cursus  nunc.  Integer  semper  turpis  et  enim   adipiscing  elit.  In  vel  nulla   por6tor  iaculis.  Nulla  facilisi.  Lorem  ipsum   arcu,  vitae  cursus  nunc.   dolor  sit  amet,  consectetur  adipiscing  elit.   Integer  semper  turpis  et   Mauris  vehicula  ves;bulum  dictum.   enim  por6tor  iaculis.   Aenean  non  velit  tortor.  Nullam  adipiscing   Nulla  facilisi.  Lorem  ipsum   malesuada  aliquam.  Mauris  dignissim,  urna   dolor  sit  amet,   quis  iaculis  tempus,  justo  libero  por6tor   consectetur  adipiscing  elit.   est,  nec  eleifend  est  elit  vitae  ante.   Mauris  vehicula   Curabitur  interdum  luctus  metus,  in   ves;bulum  dictum.   pulvinar  lectus  rutrum  sit  amet.  Duis   Aenean  non  velit  tortor.   gravida,  metus  in  dictum  eleifend,  dolor   Nullam  adipiscing   risus  ;ncidunt  ligula,  non  volutpat  nulla   malesuada  aliquam.   sapien  in  elit.  Nulla  rutrum  erat  id  neque   Mauris  dignissim,  urna   suscipit  eu  ultricies  odio  sollicitudin.   quis  iaculis  tempus,  justo   Aliquam  a  mi  vel  eros  placerat  hendrerit.   libero  por6tor  est,  nec   Phasellus  por6tor,  augue  sit  amet   eleifend  est  elit  vitae  ante.   vulputate  venena;s,  dui  leo  commodo   Curabitur  interdum  luctus   odio,  a  euismod  turpis  ligula  in  elit.     metus.  
  • 117. <esi:include src="..." /> Lorem  ipsum  dolor  sit  amet,  consectetur   adipiscing  elit.  In  vel  nulla  arcu,  vitae   cursus  nunc.  Integer  semper  turpis  et  enim   por6tor  iaculis.  Nulla  facilisi.  Lorem  ipsum   dolor  sit  amet,  consectetur  adipiscing  elit.   Mauris  vehicula  ves;bulum  dictum.   Aenean  non  velit  tortor.  Nullam  adipiscing   malesuada  aliquam.  Mauris  dignissim,  urna   quis  iaculis  tempus,  justo  libero  por6tor   est,  nec  eleifend  est  elit  vitae  ante.   Curabitur  interdum  luctus  metus,  in   pulvinar  lectus  rutrum  sit  amet.  Duis   gravida,  metus  in  dictum  eleifend,  dolor   risus  ;ncidunt  ligula,  non  volutpat  nulla   sapien  in  elit.  Nulla  rutrum  erat  id  neque   suscipit  eu  ultricies  odio  sollicitudin.   Aliquam  a  mi  vel  eros  placerat  hendrerit.   Phasellus  por6tor,  augue  sit  amet   vulputate  venena;s,  dui  leo  commodo   odio,  a  euismod  turpis  ligula  in  elit.    
  • 118. ESI… or Edge Side Includes
  • 119. Lorem  ipsum   dolor  sit   amet,     1 2 Symfony2 Application Lorem   ipsum   Reverse Proxy dolor   Client 3 Lorem  ipsum   Lorem   dolor  sit   ipsum   amet,     dolor   4
  • 120. Web Server Symfony2 app Requests Response
  • 121. Web Server Symfony2 HTTP proxy Symfony2 app Requests Response
  • 122. Reverse proxy Web Server Symfony2 app Requests Response
  • 124. Request core.request getController() core.controller getArguments() core.view core.response Response
  • 125. Request core.request getController() core.controller core.exception getArguments() core.view core.response Response
  • 126. SwiftmailerBundle DoctrineBundle ZendBundle ... FrameworkBundle TwigBundle Bundles Components HttpKernel DependencyInjection Console Routing Templating HttpFoundation Event Dispatcher ...