Slide 1

Slide 1 text

Starting with

Slide 2

Slide 2 text

@zenstruck About Me ● Kevin Bond ● Kitchener, Ontario ● PHP Developer – Symfony2 core/docs contributor [email protected] zenstruck.com

Slide 3

Slide 3 text

@zenstruck What is Symfony2?

Slide 4

Slide 4 text

@zenstruck What is Symfony2? ● Set of stand-alone, decoupled components

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

@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

Slide 7

Slide 7 text

@zenstruck Symfony2 Components DependencyInjection EventDispatcher HttpFoundation DomCrawler ClassLoader CssSelector HttpKernel BrowserKit Templating Translation Serializer Validator Security Routing Console Process Config Finder Locale Yaml Form

Slide 8

Slide 8 text

@zenstruck Projects using Symfony2 ● Assetic (Process) ● Doctrine2 (Console) ● PHPUnit (Yaml) ● Behat ● Silex ● Drupal 8 ● Propel

Slide 9

Slide 9 text

@zenstruck Why use Symfony2? ● Fast ● PHP 5.3 ● Well engineered (no singletons) ● Forces* best practices ● Extensible and flexible ● Stable and established ● Testable

Slide 10

Slide 10 text

@zenstruck What Symfony2 is not

Slide 11

Slide 11 text

@zenstruck What Symfony2 is not MVC Framework

Slide 12

Slide 12 text

@zenstruck What Symfony2 is not MVC Framework

Slide 13

Slide 13 text

@zenstruck HTTP Framework Request Response

Slide 14

Slide 14 text

@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

Slide 15

Slide 15 text

@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

Slide 16

Slide 16 text

@zenstruck Useful Bundles ● FOSUserBundle ● FOSFacebookBundle ● KnpMenuBundle ● SonataAdminBundle ● FOSJsRoutingBundle ● OAuthBundle ● JMSI18nRoutingBundle

Slide 17

Slide 17 text

@zenstruck Anatomy of a Request

Slide 18

Slide 18 text

@zenstruck Anatomy of a Request ● Request

Slide 19

Slide 19 text

@zenstruck Anatomy of a Request ● Request ● Kernel

Slide 20

Slide 20 text

@zenstruck Anatomy of a Request ● Request ● Kernel ● Controller

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

@zenstruck Anatomy of a Request ● Request ● Kernel ● Controller ● Exception? ● Response (html, json, xml, etc...)

Slide 23

Slide 23 text

Service Container

Slide 24

Slide 24 text

@zenstruck Get Started curl -s http://getcomposer.org/installer | php composer.phar create-project symfony/framework-standard-edition path/to/install

Slide 25

Slide 25 text

Demo

Slide 26

Slide 26 text

@zenstruck “Killer” Feature

Slide 27

Slide 27 text

@zenstruck “Killer” Feature Symfony2 Reverse Proxy

Slide 28

Slide 28 text

@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.

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

@zenstruck Symfony2 Reverse Proxy ● Request ● Reverse Proxy ● Cached version? ● Kernel ● Controller ● Response (html, json, xml, etc...) ● Set s-maxage header

Slide 33

Slide 33 text

@zenstruck Caching Dynamic Content

Slide 34

Slide 34 text

@zenstruck Caching Dynamic Content ● Sub-requests

Slide 35

Slide 35 text

@zenstruck Caching Dynamic Content ● Sub-requests ● ESI – Edge Side Includes – Server side sub-requests

Slide 36

Slide 36 text

@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

Slide 37

Slide 37 text

@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