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

Más contenido relacionado

La actualidad más candente

Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Github.com anton terekhov-orientdb-php
Github.com anton terekhov-orientdb-phpGithub.com anton terekhov-orientdb-php
Github.com anton terekhov-orientdb-php
San jay
 

La actualidad más candente (20)

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

Similar a MidwestPHP Symfony2 Internals

Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
Hiroshi Nakamura
 
Tips
TipsTips
Tips
mclee
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
patter
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
lestrrat
 
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-servicenguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
hazzaz
 

Similar a MidwestPHP Symfony2 Internals (20)

Static Analysis of PHP Code – IPC Berlin 2016
Static Analysis of PHP Code – IPC Berlin 2016Static Analysis of PHP Code – IPC Berlin 2016
Static Analysis of PHP Code – IPC Berlin 2016
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
 
From CakePHP to Laravel
From CakePHP to LaravelFrom CakePHP to Laravel
From CakePHP to Laravel
 
Creating your own framework on top of Symfony2 Components
Creating your own framework on top of Symfony2 ComponentsCreating your own framework on top of Symfony2 Components
Creating your own framework on top of Symfony2 Components
 
Writing and using php streams and sockets tek11
Writing and using php streams and sockets   tek11Writing and using php streams and sockets   tek11
Writing and using php streams and sockets tek11
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
 
Php 7 compliance workshop singapore
Php 7 compliance workshop singaporePhp 7 compliance workshop singapore
Php 7 compliance workshop singapore
 
Rest with Spring
Rest with SpringRest with Spring
Rest with Spring
 
Kubernetes API code-base tour
Kubernetes API code-base tourKubernetes API code-base tour
Kubernetes API code-base tour
 
Tips
TipsTips
Tips
 
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Cli the other sapi pbc11
Cli the other sapi pbc11Cli the other sapi pbc11
Cli the other sapi pbc11
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
 
Is your python application secure? - PyCon Canada - 2015-11-07
Is your python application secure? - PyCon Canada - 2015-11-07Is your python application secure? - PyCon Canada - 2015-11-07
Is your python application secure? - PyCon Canada - 2015-11-07
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
PyCon Canada 2015 - Is your python application secure
PyCon Canada 2015 - Is your python application securePyCon Canada 2015 - Is your python application secure
PyCon Canada 2015 - Is your python application secure
 
Cli the other SAPI confoo11
Cli the other SAPI confoo11Cli the other SAPI confoo11
Cli the other SAPI confoo11
 
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-servicenguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
 

Más de Raul Fraile

Presentacion Symfony2
Presentacion Symfony2Presentacion Symfony2
Presentacion Symfony2
Raul Fraile
 

Más de Raul Fraile (17)

Aplicaciones CLI profesionales con Symfony
Aplicaciones CLI profesionales con SymfonyAplicaciones CLI profesionales con Symfony
Aplicaciones CLI profesionales con Symfony
 
Steganography: Hiding your secrets with PHP
Steganography: Hiding your secrets with PHPSteganography: Hiding your secrets with PHP
Steganography: Hiding your secrets with PHP
 
How GZIP compression works - JS Conf EU 2014
How GZIP compression works - JS Conf EU 2014How GZIP compression works - JS Conf EU 2014
How GZIP compression works - JS Conf EU 2014
 
How GZIP works... in 10 minutes
How GZIP works... in 10 minutesHow GZIP works... in 10 minutes
How GZIP works... in 10 minutes
 
Symfony en Drupal 8 - DrupalCamp Spain
Symfony en Drupal 8 - DrupalCamp Spain Symfony en Drupal 8 - DrupalCamp Spain
Symfony en Drupal 8 - DrupalCamp Spain
 
$kernel->infect(): Creating a cryptovirus for Symfony2 apps
$kernel->infect(): Creating a cryptovirus for Symfony2 apps$kernel->infect(): Creating a cryptovirus for Symfony2 apps
$kernel->infect(): Creating a cryptovirus for Symfony2 apps
 
Materiales del curso de Symfony2
Materiales del curso de Symfony2Materiales del curso de Symfony2
Materiales del curso de Symfony2
 
Sistemas de ficheros para dispositivos embebidos
Sistemas de ficheros para dispositivos embebidosSistemas de ficheros para dispositivos embebidos
Sistemas de ficheros para dispositivos embebidos
 
Refactoring PHP/Symfony2 apps
Refactoring PHP/Symfony2 appsRefactoring PHP/Symfony2 apps
Refactoring PHP/Symfony2 apps
 
Refactorización de aplicaciones PHP/Symfony2
Refactorización de aplicaciones PHP/Symfony2Refactorización de aplicaciones PHP/Symfony2
Refactorización de aplicaciones PHP/Symfony2
 
Symfony internals [english]
Symfony internals [english]Symfony internals [english]
Symfony internals [english]
 
DeSymfony 2012: Symfony internals
DeSymfony 2012: Symfony internalsDeSymfony 2012: Symfony internals
DeSymfony 2012: Symfony internals
 
Symfony2: Interacción con CSS, JS y HTML5
Symfony2: Interacción con CSS, JS y HTML5Symfony2: Interacción con CSS, JS y HTML5
Symfony2: Interacción con CSS, JS y HTML5
 
Symfony2: Optimización y rendimiento
Symfony2: Optimización y rendimientoSymfony2: Optimización y rendimiento
Symfony2: Optimización y rendimiento
 
Symfony2: Framework para PHP5
Symfony2: Framework para PHP5Symfony2: Framework para PHP5
Symfony2: Framework para PHP5
 
Symfony2: Framework para PHP5
Symfony2: Framework para PHP5Symfony2: Framework para PHP5
Symfony2: Framework para PHP5
 
Presentacion Symfony2
Presentacion Symfony2Presentacion Symfony2
Presentacion Symfony2
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

MidwestPHP Symfony2 Internals