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)

DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
Teaching material agriculture food technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
A Presentation on Artificial Intelligence
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Modernizing your data center with Dell and AMD
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
The AUB Centre for AI in Media Proposal.docx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Network Security Unit 5.pdf for BCA BBA.
Teaching material agriculture food technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Chapter 3 Spatial Domain Image Processing.pdf
20250228 LYD VKU AI Blended-Learning.pptx
A Presentation on Artificial Intelligence
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Modernizing your data center with Dell and AMD
Building Integrated photovoltaic BIPV_UPV.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation_ Review paper, used for researhc scholars
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity

MidwestPHP Symfony2 Internals