Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Starting with Symfony2

Starting with Symfony2

Kevin Bond

June 28, 2012
Tweet

More Decks by Kevin Bond

Other Decks in Programming

Transcript

  1. @zenstruck About Me • Kevin Bond • Kitchener, Ontario •

    PHP Developer – Symfony2 core/docs contributor [email protected] zenstruck.com
  2. @zenstruck What is Symfony2? • Set of stand-alone, decoupled components

    • Full-stack framework based on these components
  3. @zenstruck What is Symfony2? • Set of stand-alone, decoupled components

    • Full-stack framework based on these components • Community • Forum/Mailing List/IRC (#symfony on Freenode) • 3rd party bundles (knpbundles.com) • 5000+ watchers / 1300+ forks • 560+ unique contributors
  4. @zenstruck Symfony2 Components DependencyInjection EventDispatcher HttpFoundation DomCrawler ClassLoader CssSelector HttpKernel

    BrowserKit Templating Translation Serializer Validator Security Routing Console Process Config Finder Locale Yaml Form
  5. @zenstruck Projects using Symfony2 • Assetic (Process) • Doctrine2 (Console)

    • PHPUnit (Yaml) • Behat • Silex • Drupal 8 • Propel
  6. @zenstruck Why use Symfony2? • Fast • PHP 5.3 •

    Well engineered (no singletons) • Forces* best practices • Extensible and flexible • Stable and established • Testable
  7. @zenstruck HTTP Framework Request Response I don't like MVC because

    that's not how the web works. Symfony2 is an HTTP framework; it is a Request/Response framework. That's the big deal. The fundamental principles of Symfony2 are centered around the HTTP specification. - Fabien Potencier
  8. @zenstruck Bundles • Everything is a bundle (even the framework

    is a collection of core bundles) • Bundles contain: • Configuration/Translations/Documentation • Routes/Controllers/Views • Public resources (js/css/images) • Services/Events/Models/Forms etc (* don't make your bundle a library) • Tests • NOT VENDOR LIBS • Override with child bundle • 690+ bundles on knpbundles.com
  9. @zenstruck Useful Bundles • FOSUserBundle • FOSFacebookBundle • KnpMenuBundle •

    SonataAdminBundle • FOSJsRoutingBundle • OAuthBundle • JMSI18nRoutingBundle
  10. @zenstruck Anatomy of a Request • Request • Kernel •

    Controller • Response (html, json, xml, etc...)
  11. @zenstruck Anatomy of a Request • Request • Kernel •

    Controller • Exception? • Response (html, json, xml, etc...)
  12. @zenstruck 3 Types of HTTP Cache • From the docs:

    • Browser caches: Every browser comes with its own local cache that is mainly useful for when you hit "back" or for images and other assets. The browser cache is a private cache as cached resources aren't shared with anyone else. • Proxy caches: A proxy is a shared cache as many people can be behind a single one. It's usually installed by large corporations and ISPs to reduce latency and network traffic. • Gateway caches: Like a proxy, it's also a shared cache but on the server side. Installed by network administrators, it makes websites more scalable, reliable and performant.
  13. @zenstruck Symfony2 Reverse Proxy • Request • Reverse Proxy •

    Kernel • Controller • Response (html, json, xml, etc...)
  14. @zenstruck Symfony2 Reverse Proxy • Request • Reverse Proxy •

    Kernel • Controller • Response (html, json, xml, etc...) • Set s-maxage header
  15. @zenstruck Symfony2 Reverse Proxy • Request • Reverse Proxy •

    Cached version? • Kernel • Controller • Response (html, json, xml, etc...) • Set s-maxage header
  16. @zenstruck Caching Dynamic Content • Sub-requests • ESI – Edge

    Side Includes – Server side sub-requests • CSI – Client Side Includes (new in 2.1) – Uses javascript (hinclude.js) – Client side sub-requests
  17. @zenstruck Resources • github.com/kbond/gpug-symfony2 • symfony.com (docs/cookbook) • fabien.potencier.org •

    knpbundles.com • richardmiller.co.uk • knpuniversity.com • connect.sensiolabs.com • live.symfony.com • mnot.github.com/hinclude