SlideShare a Scribd company logo
Symfony2 Internals
      Raúl Fraile
Who am I?
Raúl Fraile

 • Software developer at
 • I live in Spain
 • PHP 5.3 Zend Certified Engineer
 • Symfony Certified Developer
 • Symfony2 lover ❤
 • LadybugPHP: Simple and extensible PHP dumper
 • Future dad ☺
                  @raulfraile
Should I care about
Symfony2 internals?
MidwestPHP Symfony2 Internals
Yes!
MidwestPHP Symfony2 Internals
http://xkcd.com/676/
Topics
1. Symfony2 components
2. Composer
3. Autoloading & PSR-0
4. Request & Response
5. Demo 1
6. Symfony2 full-stack framework
7. Events
8. Demo 2
Components
Set of decoupled and
 standalone libraries
Implement common features
  needed to develop websites
The foundation of the
Symfony2 full-stack framework
BrowserKit            Finder         Security

   ClassLoader             Form         Serializer

      Config           HttpFoundation    Templating

     Console            HttpKernel      Translation

    CssSelector           Locale         Validator

DependencyInjection       Process          Yaml

   DomCrawler         OptionsResolver

  EventDispatcher         Routing
BrowserKit            Finder           Security

   ClassLoader             Form           Serializer

      Config           HttpFoundation      Templating

     Console            HttpKernel        Translation

    CssSelector           Locale           Validator

DependencyInjection       Process            Yaml

   DomCrawler         OptionsResolver   PropertyAccess
                                                         2.2.0
  EventDispatcher         Routing         StopWatch
Who’s using them?
Components demo...
... after some concepts
Composer
MidwestPHP Symfony2 Internals
Composer is a dependency
   manager for PHP
{
    "require": {
        "symfony/http-foundation": "v2.2.0",
        "doctrine/orm": ">=2.2.3",
    }
}
$ composer install
Autoload
Triggered whenever we need a class
 or interface not already defined
Fully Qualified Name (FQN)




           File
Fully Qualified Name (FQN)
∖Doctrine∖DBAL∖Driver




                        File
Fully Qualified Name (FQN)
 ∖Doctrine∖DBAL∖Driver




[lib_path]/Doctrine/DBAL/Driver.php



                                  File
Fully Qualified Name (FQN)
 ∖Doctrine∖DBAL∖Driver
 ∖Twig_Lexer




[lib_path]/Doctrine/DBAL/Driver.php



                                  File
Fully Qualified Name (FQN)
 ∖Doctrine∖DBAL∖Driver
 ∖Twig_Lexer




[lib_path]/Doctrine/DBAL/Driver.php
[lib_path]/Twig/Lexer.php

                                  File
bool spl_autoload_register(
  [callable $autoload_function,
  [bool $throw = true,
  [bool $prepend = false]]]
)
<?php
 
include_once(__DIR__.'/MyLoader.php');
include_once(__DIR__.'/vendor/Twitter/Loader.php');
 
spl_autoload_register(array('MyLoader', 'autoload'));
spl_autoload_register(array('Loader', 'autoload'));

$tweet = new Tweet(); // vendor/Twitter/Tweet.php
$book = new MyBook(); // classes/My/Book.php
<?php
 
include_once(__DIR__.'/MyLoader.php');
include_once(__DIR__.'/vendor/Twitter/Loader.php');
 
spl_autoload_register(array('MyLoader', 'autoload'));
spl_autoload_register(array('Loader', 'autoload'));

$tweet = new Tweet(); // vendor/Twitter/Tweet.php
$book = new MyBook(); // classes/My/Book.php


   new Tweet()
<?php
 
include_once(__DIR__.'/MyLoader.php');
include_once(__DIR__.'/vendor/Twitter/Loader.php');
 
spl_autoload_register(array('MyLoader', 'autoload'));
spl_autoload_register(array('Loader', 'autoload'));

$tweet = new Tweet(); // vendor/Twitter/Tweet.php
$book = new MyBook(); // classes/My/Book.php


   new Tweet()   MyLoader::autoload(‘Tweet’)
<?php
 
include_once(__DIR__.'/MyLoader.php');
include_once(__DIR__.'/vendor/Twitter/Loader.php');
 
spl_autoload_register(array('MyLoader', 'autoload'));
spl_autoload_register(array('Loader', 'autoload'));

$tweet = new Tweet(); // vendor/Twitter/Tweet.php
$book = new MyBook(); // classes/My/Book.php


   new Tweet()   MyLoader::autoload(‘Tweet’)   Loader::autoload(‘Tweet’)
<?php
 
include_once(__DIR__.'/MyLoader.php');
include_once(__DIR__.'/vendor/Twitter/Loader.php');
 
spl_autoload_register(array('MyLoader', 'autoload'));
spl_autoload_register(array('Loader', 'autoload'));

$tweet = new Tweet(); // vendor/Twitter/Tweet.php
$book = new MyBook(); // classes/My/Book.php


   new Tweet()   MyLoader::autoload(‘Tweet’)         Loader::autoload(‘Tweet’)



                                    include __DIR__.’/vendor/Twitter/Tweet.php’
This is a mess...
... we need a standard!
PSR-0
F.I.G

Framework Interop Group
In summary:

1) ‘/’ and ‘_’ are converted to
  DIRECTORY_SEPARATOR
2) Suffixed with .php
Time for the demo!
Request
HttpFoundation Component

Object Oriented abstraction of an
        HTTP request
http://www.ietf.org/rfc/rfc2616.txt



Request = Request-Line
           *(header CRLF)
          CRLF
          [ message-body ]
http://www.ietf.org/rfc/rfc2616.txt
                    Request-Line
 =
 Method
 SP
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Request-URI
 SP
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 HTTP-Version
 CRLF
Request = Request-Line
           *(header CRLF)
          CRLF
          [ message-body ]
http://www.ietf.org/rfc/rfc2616.txt
                                                                                                                                 Request-Line
 =
 Method
 SP
 
 
 
 

More Related Content

PPT
Hacking with hhvm
PDF
Fluentd meetup at Slideshare
PDF
Submit PHP: Standards in PHP world. Михайло Морозов
PDF
Getting Into FLOW3 (DPC12)
PDF
IPCSE12: Getting into FLOW3
ODP
LD_PRELOAD Exploitation - DC9723
PDF
Something About Dynamic Linking
DOC
Use perl creating web services with xml rpc
Hacking with hhvm
Fluentd meetup at Slideshare
Submit PHP: Standards in PHP world. Михайло Морозов
Getting Into FLOW3 (DPC12)
IPCSE12: Getting into FLOW3
LD_PRELOAD Exploitation - DC9723
Something About Dynamic Linking
Use perl creating web services with xml rpc

What's hot (20)

PDF
upload test 1
PDF
How to collect Big Data into Hadoop
PPT
PHPBootcamp - Zend Framework
PPTX
Streams, sockets and filters oh my!
PPT
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
PPTX
HipHop Virtual Machine
PDF
Github.com anton terekhov-orientdb-php
PPT
Introduction to php php++
PPTX
06 - ELF format, knowing your friend
PDF
Yapc::NA::2009 - Command Line Perl
PDF
Debugging on rails
PDF
HHVM and Hack: A quick introduction
PDF
Spl in the wild
PPT
typemap in Perl/XS
PDF
Fighting API Compatibility On Fluentd Using "Black Magic"
PDF
Information security programming in ruby
PDF
Strategies to improve embedded Linux application performance beyond ordinary ...
KEY
Puppet NBLUG 2008-09
PDF
upload test 1
How to collect Big Data into Hadoop
PHPBootcamp - Zend Framework
Streams, sockets and filters oh my!
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
HipHop Virtual Machine
Github.com anton terekhov-orientdb-php
Introduction to php php++
06 - ELF format, knowing your friend
Yapc::NA::2009 - Command Line Perl
Debugging on rails
HHVM and Hack: A quick introduction
Spl in the wild
typemap in Perl/XS
Fighting API Compatibility On Fluentd Using "Black Magic"
Information security programming in ruby
Strategies to improve embedded Linux application performance beyond ordinary ...
Puppet NBLUG 2008-09
Ad

Similar to MidwestPHP Symfony2 Internals (20)

PDF
Symfony components in the wild, PHPNW12
PDF
Symfony internals [english]
PDF
Symfony without the framework
PDF
Symfony 2 (PHP day 2009)
PDF
Symfony 2 (PHP Quebec 2009)
PDF
Build powerfull and smart web applications with Symfony2
PDF
Symfony As A Platform (Symfony Camp 2007)
KEY
Phpne august-2012-symfony-components-friends
PDF
Symfony 2.0
PPTX
Day02 a pi.
PDF
Drupal users group_symfony2
PDF
Symfony 2.0 on PHP 5.3
PDF
Symfony2 San Francisco Meetup 2009
PDF
CGI.pm - 3ло?!
KEY
Anatomy of a PHP Request ( UTOSC 2010 )
PDF
Mod Perl Quick Reference Card
PPTX
Ran Mizrahi - Symfony2 meets Drupal8
PDF
Welcome to the Symfony2 World - FOSDEM 2013
PPTX
RESTful modules in zf2
PDF
TYPO3 Flow and the Joy of Development (FOSDEM 2013)
Symfony components in the wild, PHPNW12
Symfony internals [english]
Symfony without the framework
Symfony 2 (PHP day 2009)
Symfony 2 (PHP Quebec 2009)
Build powerfull and smart web applications with Symfony2
Symfony As A Platform (Symfony Camp 2007)
Phpne august-2012-symfony-components-friends
Symfony 2.0
Day02 a pi.
Drupal users group_symfony2
Symfony 2.0 on PHP 5.3
Symfony2 San Francisco Meetup 2009
CGI.pm - 3ло?!
Anatomy of a PHP Request ( UTOSC 2010 )
Mod Perl Quick Reference Card
Ran Mizrahi - Symfony2 meets Drupal8
Welcome to the Symfony2 World - FOSDEM 2013
RESTful modules in zf2
TYPO3 Flow and the Joy of Development (FOSDEM 2013)
Ad

More from Raul Fraile (16)

PDF
Aplicaciones CLI profesionales con Symfony
PDF
Steganography: Hiding your secrets with PHP
PDF
How GZIP compression works - JS Conf EU 2014
PDF
How GZIP works... in 10 minutes
PDF
Symfony en Drupal 8 - DrupalCamp Spain
PDF
$kernel->infect(): Creating a cryptovirus for Symfony2 apps
PDF
Materiales del curso de Symfony2
PDF
Sistemas de ficheros para dispositivos embebidos
PDF
Refactoring PHP/Symfony2 apps
PDF
Refactorización de aplicaciones PHP/Symfony2
PDF
DeSymfony 2012: Symfony internals
PPT
Symfony2: Interacción con CSS, JS y HTML5
PPT
Symfony2: Optimización y rendimiento
PDF
Symfony2: Framework para PHP5
ODP
Symfony2: Framework para PHP5
PDF
Presentacion Symfony2
Aplicaciones CLI profesionales con Symfony
Steganography: Hiding your secrets with PHP
How GZIP compression works - JS Conf EU 2014
How GZIP works... in 10 minutes
Symfony en Drupal 8 - DrupalCamp Spain
$kernel->infect(): Creating a cryptovirus for Symfony2 apps
Materiales del curso de Symfony2
Sistemas de ficheros para dispositivos embebidos
Refactoring PHP/Symfony2 apps
Refactorización de aplicaciones PHP/Symfony2
DeSymfony 2012: Symfony internals
Symfony2: Interacción con CSS, JS y HTML5
Symfony2: Optimización y rendimiento
Symfony2: Framework para PHP5
Symfony2: Framework para PHP5
Presentacion Symfony2

Recently uploaded (20)

PDF
Advanced IT Governance
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPT
Teaching material agriculture food technology
PDF
KodekX | Application Modernization Development
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
Advanced IT Governance
NewMind AI Weekly Chronicles - August'25 Week I
Understanding_Digital_Forensics_Presentation.pptx
madgavkar20181017ppt McKinsey Presentation.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Chapter 3 Spatial Domain Image Processing.pdf
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Dropbox Q2 2025 Financial Results & Investor Presentation
Teaching material agriculture food technology
KodekX | Application Modernization Development
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Reach Out and Touch Someone: Haptics and Empathic Computing
The Rise and Fall of 3GPP – Time for a Sabbatical?

MidwestPHP Symfony2 Internals