midwestphp symfony2 internals
TRANSCRIPT
![Page 1: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/1.jpg)
Symfony2 InternalsRaúl Fraile
![Page 2: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/2.jpg)
Who am I?
![Page 3: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/3.jpg)
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
![Page 4: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/4.jpg)
Should I care aboutSymfony2 internals?
![Page 5: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/5.jpg)
![Page 6: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/6.jpg)
Yes!
![Page 7: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/7.jpg)
![Page 9: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/9.jpg)
Topics
![Page 10: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/10.jpg)
1. Symfony2 components2. Composer3. Autoloading & PSR-04. Request & Response5. Demo 16. Symfony2 full-stack framework7. Events8. Demo 2
![Page 11: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/11.jpg)
Components
![Page 12: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/12.jpg)
Set of decoupled and standalone libraries
![Page 13: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/13.jpg)
Implement common features needed to develop websites
![Page 14: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/14.jpg)
The foundation of the Symfony2 full-stack framework
![Page 15: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/15.jpg)
BrowserKit
ClassLoader
Config
Console
CssSelector
DependencyInjection
DomCrawler
EventDispatcher
Finder
Form
HttpFoundation
HttpKernel
Locale
Process
Routing
Security
Serializer
Templating
Translation
Validator
Yaml
OptionsResolver
![Page 16: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/16.jpg)
BrowserKit
ClassLoader
Config
Console
CssSelector
DependencyInjection
DomCrawler
EventDispatcher
Finder
Form
HttpFoundation
HttpKernel
Locale
Process
Routing
Security
Serializer
Templating
Translation
Validator
Yaml
StopWatch
PropertyAccess
2.2.0OptionsResolver
![Page 17: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/17.jpg)
Who’s using them?
![Page 18: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/18.jpg)
Components demo...
![Page 19: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/19.jpg)
... after some concepts
![Page 20: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/20.jpg)
Composer
![Page 21: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/21.jpg)
![Page 22: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/22.jpg)
Composer is a dependency manager for PHP
![Page 23: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/23.jpg)
{ "require": { "symfony/http-foundation": "v2.2.0", "doctrine/orm": ">=2.2.3", }}
![Page 24: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/24.jpg)
$ composer install
![Page 25: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/25.jpg)
Autoload
![Page 26: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/26.jpg)
Triggered whenever we need a class or interface not already defined
![Page 27: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/27.jpg)
Fully Quali!ed Name (FQN)
File
![Page 28: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/28.jpg)
Fully Quali!ed Name (FQN)
File
∖Doctrine∖DBAL∖Driver
![Page 29: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/29.jpg)
Fully Quali!ed Name (FQN)
File
∖Doctrine∖DBAL∖Driver
[lib_path]/Doctrine/DBAL/Driver.php
![Page 30: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/30.jpg)
Fully Quali!ed Name (FQN)
File
∖Doctrine∖DBAL∖Driver
∖Twig_Lexer
[lib_path]/Doctrine/DBAL/Driver.php
![Page 31: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/31.jpg)
Fully Quali!ed Name (FQN)
File
∖Doctrine∖DBAL∖Driver
∖Twig_Lexer
[lib_path]/Doctrine/DBAL/Driver.php
[lib_path]/Twig/Lexer.php
![Page 32: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/32.jpg)
bool spl_autoload_register( [callable $autoload_function, [bool $throw = true, [bool $prepend = false]]])
![Page 33: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/33.jpg)
<?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
![Page 34: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/34.jpg)
<?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()
![Page 35: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/35.jpg)
<?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’)
![Page 36: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/36.jpg)
<?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’)
![Page 37: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/37.jpg)
<?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’
![Page 38: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/38.jpg)
This is a mess...
![Page 39: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/39.jpg)
... we need a standard!
![Page 40: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/40.jpg)
PSR-0
![Page 41: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/41.jpg)
F.I.G
Framework Interop Group
![Page 42: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/42.jpg)
In summary:
1) ‘/’ and ‘_’ are converted to DIRECTORY_SEPARATOR2) Suffixed with .php
![Page 43: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/43.jpg)
Time for the demo!
![Page 44: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/44.jpg)
Request
![Page 45: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/45.jpg)
HttpFoundation Component
Object Oriented abstraction of an HTTP request
![Page 46: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/46.jpg)
Request = Request-Line *(header CRLF) CRLF [ message-body ]
http://www.ietf.org/rfc/rfc2616.txt
![Page 47: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/47.jpg)
Request = Request-Line *(header CRLF) CRLF [ message-body ]
http://www.ietf.org/rfc/rfc2616.txtRequest-Line����������� ������������������ =����������� ������������������ Method����������� ������������������ SP����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ Request-URI����������� ������������������ SP����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ HTTP-Version����������� ������������������ CRLF
![Page 48: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/48.jpg)
Request = Request-Line *(header CRLF) CRLF [ message-body ]
http://www.ietf.org/rfc/rfc2616.txtRequest-Line����������� ������������������ =����������� ������������������ Method����������� ������������������ SP����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ Request-URI����������� ������������������ SP����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ HTTP-Version����������� ������������������ CRLF
General����������� ������������������ headers:����������� ������������������ Cache-Control,����������� ������������������ Transfer-Encoding,����������� ������������������ Via...Request����������� ������������������ headers:����������� ������������������ Accept-Encoding,����������� ������������������ Accept-Language,����������� ������������������ If-Match...Entity����������� ������������������ headers:����������� ������������������ Content-Encoding,����������� ������������������ Content-Language,����������� ������������������ Expires...
![Page 49: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/49.jpg)
GET /index.php HTTP/1.1Host: test.comAccept-Language:en;q=0.8Accept-Encoding:gzipUser-Agent: Mozilla/5.0
Hypertext Transfer Protocol
![Page 50: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/50.jpg)
GET /index.php HTTP/1.1Host: test.comAccept-Language:en;q=0.8Accept-Encoding:gzipUser-Agent: Mozilla/5.0
Hypertext Transfer Protocol
$_GET
$_POST
$_COOKIE
$_FILES
$_SERVER
![Page 51: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/51.jpg)
GET /index.php HTTP/1.1Host: test.comAccept-Language:en;q=0.8Accept-Encoding:gzipUser-Agent: Mozilla/5.0
Hypertext Transfer Protocol
$_GET
$_POST
$_COOKIE
$_FILES
$_SERVER
query request cookies
filesserver
headersgetHost
getClientIp...
![Page 52: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/52.jpg)
Response
![Page 53: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/53.jpg)
HttpFoundation Component
Object Oriented abstraction of an HTTP response
![Page 54: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/54.jpg)
Response = Status-Line *(header CRLF) CRLF [ message-body ]
http://www.ietf.org/rfc/rfc2616.txt
![Page 55: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/55.jpg)
Response = Status-Line *(header CRLF) CRLF [ message-body ]
http://www.ietf.org/rfc/rfc2616.txtStatus-Line����������� ������������������ =����������� ������������������ HTTP-Version����������� ������������������ SP����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ Status-Code����������� ������������������ SP����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ Reason-Phrase����������� ������������������ CRLF
![Page 56: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/56.jpg)
Response = Status-Line *(header CRLF) CRLF [ message-body ]
http://www.ietf.org/rfc/rfc2616.txtStatus-Line����������� ������������������ =����������� ������������������ HTTP-Version����������� ������������������ SP����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ Status-Code����������� ������������������ SP����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ ����������� ������������������ Reason-Phrase����������� ������������������ CRLF
General����������� ������������������ headers:����������� ������������������ Cache-Control,����������� ������������������ Pragma,����������� ������������������ Via...Response����������� ������������������ headers:����������� ������������������ ETag,����������� ������������������ Vary,����������� ������������������ WWW-Authenticate...Entity����������� ������������������ headers:����������� ������������������ Content-Encoding,����������� ������������������ Content-Language,����������� ������������������ Expires...
![Page 57: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/57.jpg)
Headers Version
Content
Status code
Status text
Charset...
![Page 58: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/58.jpg)
HTTP/1.1 200 OKContent-type: text/htmlDate:Sun, 3 Mar 2013 07:10:42 GMT
<!DOCTYPE HTML><html lang="es"> <head> <meta charset="utf-8"> ...
Hypertext Transfer Protocol
Headers Version
Content
Status code
Status text
Charset...
![Page 59: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/59.jpg)
Symfony2 full-stack framework
![Page 60: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/60.jpg)
ComponentsVendors➕BundlesBridges
---------------------Full-stack����������� ������������������ framework
+
![Page 61: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/61.jpg)
Vendors
![Page 62: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/62.jpg)
Project dependencies (third party libraries)
![Page 63: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/63.jpg)
Doctrine, Twig, Assetic, Monolog and SwiftMailer
![Page 64: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/64.jpg)
Doctrine, Twig, Assetic, Monolog and SwiftMailer
don’t����������� ������������������ reinvent����������� ������������������ the����������� ������������������ wheel,these����������� ������������������ libraries����������� ������������������ are����������� ������������������ awesome!
![Page 65: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/65.jpg)
Bundles
![Page 66: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/66.jpg)
“A bundle is a directory that has a well-defined structure and can
host anything from classes to controllers and web resources.”
Source: symfony.com
![Page 67: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/67.jpg)
FrameworkBundle
SecurityBundle
TwigBundle
WebProfilerBundle
AsseticBundle
MonologBundle
SwiftmailerBundle
![Page 68: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/68.jpg)
Bridges
![Page 69: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/69.jpg)
Extend components and libraries to be used in Symfony2
![Page 70: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/70.jpg)
Example: The Twig Bridge adds useful functions to use forms, routing, security and
translations.
![Page 71: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/71.jpg)
Example: The Twig Bridge adds useful functions to use forms, routing, security and
translations.form_enctypeform_widgetform_errorsform_labelform_rowform_restcsrf_token
![Page 72: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/72.jpg)
Example: The Twig Bridge adds useful functions to use forms, routing, security and
translations.form_enctypeform_widgetform_errorsform_labelform_rowform_restcsrf_token
urlpath
![Page 73: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/73.jpg)
Example: The Twig Bridge adds useful functions to use forms, routing, security and
translations.form_enctypeform_widgetform_errorsform_labelform_rowform_restcsrf_token
urlpath
is_granted
![Page 74: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/74.jpg)
Example: The Twig Bridge adds useful functions to use forms, routing, security and
translations.form_enctypeform_widgetform_errorsform_labelform_rowform_restcsrf_token
urlpath
is_granted
transtranschoice
![Page 75: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/75.jpg)
Events
![Page 76: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/76.jpg)
EventDispatcher Component
![Page 77: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/77.jpg)
Mediator pattern: decouple a Producer from a
Consumer
Producer
Consumer
Consumer
Consumer
![Page 78: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/78.jpg)
Mediator pattern: decouple a Producer from a
Consumer
Producer
Consumer
Consumer
Consumer
Mediator
![Page 79: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/79.jpg)
Mediator pattern: decouple a Producer from a
Consumer
Producer
Consumer
Consumer
Consumer
Mediator
addListener()dispatch()
![Page 80: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/80.jpg)
Mediator pattern: decouple a Producer from a
Consumer
Producer
Consumer
Consumer
Consumer
Mediator
addListener()dispatch()
http://goo.gl/Fr16ZMediators - Programming With Anthony
![Page 81: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/81.jpg)
kernel.request
![Page 82: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/82.jpg)
Dispatched as soon as the request arrives
![Page 83: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/83.jpg)
If any listener return a Response object, all other
listeners won't be called.
![Page 84: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/84.jpg)
Used by FrameworkBundle to populate the _controller value
![Page 85: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/85.jpg)
kernel.controller
![Page 86: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/86.jpg)
Once the controller is resolved, this event is dispatched
![Page 87: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/87.jpg)
kernel.view
![Page 88: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/88.jpg)
Called only if the controller does not return a Response
![Page 89: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/89.jpg)
Goal: build a Response object from the return value
of the Controller
![Page 90: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/90.jpg)
kernel.response
![Page 91: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/91.jpg)
Allow to modify or replace the Response object after its creation
![Page 92: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/92.jpg)
Allow to modify or replace the Response object after its creation
i.e.����������� ������������������ adding����������� ������������������ the����������� ������������������ Google����������� ������������������ Analytics����������� ������������������ tracker����������� ������������������ code?
![Page 93: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/93.jpg)
Allow to modify or replace the Response object after its creation
i.e.����������� ������������������ adding����������� ������������������ the����������� ������������������ Google����������� ������������������ Analytics����������� ������������������ tracker����������� ������������������ code?
You����������� ������������������ could...����������� ������������������ but����������� ������������������ there����������� ������������������ are����������� ������������������ better����������� ������������������ ways����������� ������������������ ☺
![Page 94: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/94.jpg)
kernel.terminate
![Page 95: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/95.jpg)
Called once the Response has been sent
![Page 96: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/96.jpg)
Used to run expensive post-response jobs
![Page 97: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/97.jpg)
Used to run expensive post-response jobs
i.e.����������� ������������������ sending����������� ������������������ emails,����������� ������������������ processing����������� ������������������ data...
![Page 98: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/98.jpg)
kernel.exception
![Page 99: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/99.jpg)
Last chance to convert an Exception into a Response object
![Page 100: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/100.jpg)
Events demo
![Page 102: MidwestPHP Symfony2 Internals](https://reader033.vdocuments.mx/reader033/viewer/2022052315/554f4a7eb4c905423f8b4c89/html5/thumbnails/102.jpg)
http://www.flickr.com/photos/wavetraced/384824309/
Photos: