Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chrisjlee/2151681 to your computer and use it in GitHub Desktop.
Save chrisjlee/2151681 to your computer and use it in GitHub Desktop.
Drupalcon Denver 2012 - Symfony meets Drupal 8 by Fabien Potencier
Collaboration
- symfony code based on github
- GPL / MIT license compatible
Example of Symfony vs Drupal
- drupal_set_message() vs flash messages
- drupal team evaluated
What is symfony (version 2) ?
- symfony version 1 is totally different
- reusable set of decoupled tools
- solved problems without use other components
- borrow ideas from other languages
- full stack php framework
Developer tools
- silex microframework
- ppi
Products
- phpbb
- zilex (post nuke)
Components being used
- classloader
- httpkernel
- httpfoundation
How to get symfony
- git
- curl
- composer
Classloader component
- only load classes on demand
- symfony.com/psr0 - url that contains standard for class loader
- first require
http loader
- symfony leverages loader
- uses specification on http 1.1 rfc2616
- read the http document http://www.ietf.org/rfc/rfc2616.txt
- based on this specification
symfony response header
- nice abstraction to create a response and request
- try to be as much php compliant
- tweak the response
routing
- drupal has too many routes
- creating route in symfony
- define a pattern
- create a urlmatcher and it returns an an array, id,controller
eventdispatcher
- probably won't use in drupal 8
- create a dispatcher
- central object for event handling
- dispatcher adds a listener - event name and make it callable
- implements observer design pattern
httpkernel
- most important http code
- httpkernal interface is the only thing in you need to be compatible with all other projects
- when request comes in listeners can do something with request
- listeners can inject arguments
- if listener returns a response - skips intemediary step
- if request even doesn't provide response - create a controller
- becomes another interface
- response can be cached and converted to response
- each method returns php controller
- resolve arguments
- each response provides a terminate
- allows to be interopable
built in listener
- symfony comes with lots of listeners out of the box
- many exceptions that convert to response
http testing
- kernal allows ability to create tests
- allows ability to create requests in code
caching
- symfony doesn't provide any caching on application layer
- relies on http caching on ietf specification
two different caching models
1. cache-control expires - provide header with cache-control
- can be browser cache
2. validation
- last-modified
- if-modified-since
- etag
- if-none-match
Expiration over validation
- can use both methods
- proxy implemented
varnish
- symfony allows you to use http varnish http accelerator
- cannot do this if you have proprietary caching mechanism
Edge side includes
- defined by w3c - http://www.w3.org/TR/esi-lang
- example of edge side include - login form is dynamic and changing
- utilize http expiration and validation
- add esi include tags ... <esi ...
- esi allows for many different parts page to use expiration and validation (expire in 10 seconds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment