drupal users group_symfony2

65

Upload: brian-zitzow

Post on 27-Jan-2015

114 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Drupal users group_symfony2
Page 2: Drupal users group_symfony2

Symfony2 Components in Drupal8

Page 3: Drupal users group_symfony2

Symfony2 Components in Drupal8

● PHP Programmer● LAMP● Symfony2 (is my favorite)

● Javascript● PHP Meetup Organizer

Twitter: @bzitzow

Email: [email protected]

Page 4: Drupal users group_symfony2

Symfony2 Components in Drupal8

How & Why?!

Page 5: Drupal users group_symfony2

Drupal & W.S.C.C.I.Web Services and Context Core Initiative

Page 6: Drupal users group_symfony2

Drupal & W.S.C.C.I.Web Services and Context Core Initiative

The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class REST server with a first-class CMS on top of it.

Page 7: Drupal users group_symfony2

Drupal & W.S.C.C.I.Web Services and Context Core Initiative

The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class REST server with a first-class CMS on top of it.

Page 8: Drupal users group_symfony2

First Class

Page 9: Drupal users group_symfony2

First Class

The term generally implies a high level of service, importance or quality.

Source: Wikipedia

Page 10: Drupal users group_symfony2

Quality

Code Testing Anyone?

Page 11: Drupal users group_symfony2

Drupal

A First Class CMS?

Page 12: Drupal users group_symfony2

Drupal

A First Class CMS?

Page 13: Drupal users group_symfony2

Drupal

A First Class REST Server?

Page 14: Drupal users group_symfony2

Drupal

A First Class REST Server?

Page 15: Drupal users group_symfony2

Drupal W.S.C.C.I.Web Services and Context Core Initiative

The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class REST server with a first-class CMS on top of it.

Page 16: Drupal users group_symfony2

Drupal W.S.C.C.I.Web Services and Context Core Initiative

The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class REST server with a first-class CMS on top of it.

To do that, we must give Drupal a unified, powerful context system that will support smarter, context- sensitive, easily cacheable block-centric layouts and non-page responses using a robust unified plugin mechanism.

Source: http://groups.drupal.org/wscci

Page 17: Drupal users group_symfony2

Enter Cliche` Wisdom

Page 18: Drupal users group_symfony2

Symfony2

Page 19: Drupal users group_symfony2

Symfony2

A reusable set of standalone, decoupled, and cohesive PHP components that solve common web development problems.

Page 20: Drupal users group_symfony2

Symfony2

A reusable set of standalone, decoupled, and cohesive PHP components that solve common web development problems.

“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

Page 21: Drupal users group_symfony2

Symfony2 Components

● Http Kernel● Http Foundation● Event Dispatcher● Routing● Dependency Injection● Class Loader

Page 22: Drupal users group_symfony2

Symfony2 Components

● Http Kernel● Http Foundation● Event Dispatcher● Routing● Dependency Injection● Class Loader

Page 23: Drupal users group_symfony2

Symfony2 Components

● Http Kernel● Http Foundation● Event Dispatcher

Page 24: Drupal users group_symfony2

HTTP Kernel Component

The HttpKernel Component provides a structured process for converting a Request into a Response by making use of the event dispatcher.

Page 25: Drupal users group_symfony2

HTTP Kernel Component

Page 26: Drupal users group_symfony2

HTTP Kernel Component

The HttpKernel Component provides a structured process for converting a Request into a Response by making use of the event dispatcher.

Flexible enough to create: ● a full-stack framework (Symfony) ● a micro-framework (Silex) ● an advanced CMS system (Drupal)

Page 27: Drupal users group_symfony2

HTTP Kernel Component

The HttpKernel Component provides a structured process for converting a Request into a Response by making use of the event dispatcher.

Flexible enough to create: ● a full-stack framework (Symfony) ● a micro-framework (Silex) ● an advanced CMS system (Drupal)

Page 28: Drupal users group_symfony2

Symfony2 Components

● Http Kernel● Http Foundation● Event Dispatcher

Page 29: Drupal users group_symfony2

HTTP Foundation Component

The HttpFoundation Component defines an object-oriented layer for the HTTP

specification.

Page 30: Drupal users group_symfony2

HTTP Foundation Component

It is an Object-Oriented abstraction of some native PHP functions and variables:

Page 31: Drupal users group_symfony2

HTTP Foundation Component

It is an Object-Oriented abstraction of some native PHP functions and variables:

The Request class abstracts the main PHP global variables like:

● $_GET● $_POST● $_COOKIE● $_FILES● $_SERVER

Page 32: Drupal users group_symfony2

HTTP Foundation Component

It is an Object-Oriented abstraction of some native PHP functions and variables:

The Response class abstracts some PHP functions like

● Header()● Setcookie()● echo

Page 33: Drupal users group_symfony2

HTTP Foundation Component

It is an Object-Oriented abstraction of some native PHP functions and variables:

The Session class and SessionStorageInterface interface abstract session management session_*() functions.

Page 34: Drupal users group_symfony2

Symfony2 Components

● Http Kernel● Http Foundation● Event Dispatcher

Page 35: Drupal users group_symfony2

Event Dispatcher Component

Page 36: Drupal users group_symfony2

Event Dispatcher Component

● A listener (PHP object) tells a central dispatcher object that it wants to listen to an event;

Page 37: Drupal users group_symfony2

Event Dispatcher Component

● A listener (PHP object) tells a central dispatcher object that it wants to listen to an event;

● At some point, the dispatcher object is told to dispatch the event, passing with it an Event object;

Page 38: Drupal users group_symfony2

Event Dispatcher Component

● A listener (PHP object) tells a central dispatcher object that it wants to listen to an event;

● At some point, the dispatcher object is told to dispatch the event, passing with it an Event object;

● The dispatcher notifies (i.e. calls a method on) all listeners of the dispatched event, allowing each of them to make modifications to the Event object.

Page 39: Drupal users group_symfony2

Event Dispatcher Component

Page 40: Drupal users group_symfony2

Event Dispatcher Component

● Enable a system-wide plugin system● Drupal 8 will run hook system and Event

Dispatcher in parallel and power a lot of the core-level Drupal components.

● Drupal 9 – its up for discussion! “The D8 cycle will allow us to gain some experience with event subscribers, and compare them with hooks.”

● EventDispatcher more flexible (inheritance) & dependencies can be injected via the DIC.

http://drupal.org/node/1509164

Page 41: Drupal users group_symfony2

Routing Component

The Routing Component maps an HTTP request to a set of configuration variables.

Page 42: Drupal users group_symfony2

Routing Component

The Routing Component maps an HTTP request to a set of configuration variables.

● Define routes

Page 43: Drupal users group_symfony2

Routing Component

The Routing Component maps an HTTP request to a set of configuration variables.

● Define routes

● Gather information about the incoming request

Page 44: Drupal users group_symfony2

Routing Component

The Routing Component maps an HTTP request to a set of configuration variables.

● Define routes

● Gather information about the incoming request

● Match the incoming request route to the route definitions

Page 45: Drupal users group_symfony2

Routing Component

The Routing Component maps an HTTP request to a set of configuration variables.

● Define routes

– YAML

– XML

– PHP

Page 46: Drupal users group_symfony2

HTTP Kernel Component

Page 47: Drupal users group_symfony2

HTTP Kernel Component

kernel.request event

● Add more information to the Request, ● Initialize parts of the system

● Router listener ● Return a Response (denied!!!)

Page 48: Drupal users group_symfony2

HTTP Kernel Component

Page 49: Drupal users group_symfony2

HTTP Kernel Component

Page 50: Drupal users group_symfony2

HTTP Kernel Component

Resolve the controller based on routing info.

● ControllerResolver● getController()● getArguments()

Page 51: Drupal users group_symfony2

HTTP Kernel Component

Page 52: Drupal users group_symfony2

HTTP Kernel Component

kernel.controller event

● Initialize things for your app● Change the controller

Page 53: Drupal users group_symfony2

HTTP Kernel Component

Page 54: Drupal users group_symfony2

HTTP Kernel Component

HttpKernel::handle()

● Executes the controller● Passes it arguments● Controller builds response (resource)

Page 55: Drupal users group_symfony2

HTTP Kernel Component

Page 56: Drupal users group_symfony2

HTTP Kernel Component

Page 57: Drupal users group_symfony2

HTTP Kernel Component

Page 58: Drupal users group_symfony2

HTTP Kernel Component

kernel.view event

Transform a non-Response return value from a controller into a Response.

● Array to JSON● Array to HTML● Whatever you want to Whatever you want

Page 59: Drupal users group_symfony2

HTTP Kernel Component

Page 60: Drupal users group_symfony2

HTTP Kernel Component

kernel.response event

● Modify Response before it's sent● HTTP Headers● Add cookies● Change the response itself

Page 61: Drupal users group_symfony2

HTTP Kernel Component

Page 62: Drupal users group_symfony2

Symfony2 Components

Page 63: Drupal users group_symfony2

Symfony2 Components

TWIG Template Engine

Page 64: Drupal users group_symfony2

Symfony2 Components

Doctrine Annotations

Page 65: Drupal users group_symfony2

Symfony2 Components

Composer