Symfony2 - Request to Response

1,024 views

Published on

Key aspects of the road from a request to a response in Symfony2.

Published in: Software
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,024
On SlideShare
0
From Embeds
0
Number of Embeds
292
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Symfony2 - Request to Response

  1. 1. Request to Response
  2. 2. Key points ● webserver ● front controller ● Kernel ● Events & Listeners ● Controller
  3. 3. let’s visualize
  4. 4. webserver ● apache ○ htaccess ○ mod_rewrite ● ex : php composer.phar create-project symfony/framework-standard-edition /path/to/workshop-symfony 2.5.* cd /path/to/workshop-symfony php -S localhost:8080 -t web
  5. 5. ● app.php vs app_dev.php ● bootstrapping [require_once __DIR__.'/../app/bootstrap.php.cache';] ● autoloading [require_once __DIR__.'/./autoload.php';] ● create Request object [$request = Request::createFromGlobals();] ● handle & send response entry point
  6. 6. AppKernel : ● init container ● init bundles HttpKernel : ● transform Request to Response [handle()] Kernel(s) HttpKernel AppKernel AppCache
  7. 7. ● EventDispatcher Component Events & Listener
  8. 8. ● kernel.request ● kernel.controller ● kernel.view ( when no-response) ● kernel.response ● kernel.finish_request (when response should not modify) ● kernel.terminate (heavy duty stuff) ● kernel.exception (obvious) Main events
  9. 9. ● dispatched as soon as a request arrives ● add information to the request, initialize parts of the system, return response if possible ● if any listener returns response the others are not called ● ex : routing, firewall, locale kernel.request
  10. 10. ● add version information to request ● some routes should not be available in version 2 - redirect to some page kernel.request - todo
  11. 11. ● dispatched after the controller is determined ● initialize things, change the controller before executing ● ex : param converter, info collecting kernel.controller
  12. 12. ● handle a preExecute() function on all controllers kernel.controller - todo
  13. 13. ● dispatched after we have a response ● modify the response object just before it is sent ● ex : context, webdebug kernel.response
  14. 14. ● add an extra header on some routes ● change the title of the page kernel.response - todo
  15. 15. That’s all folks

×