drupal users group_symfony2

Post on 27-Jan-2015

110 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

Symfony2 Components in Drupal8

Symfony2 Components in Drupal8

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

● Javascript● PHP Meetup Organizer

Twitter: @bzitzow

Email: bzitzow@gmail.com

Symfony2 Components in Drupal8

How & Why?!

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

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.

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.

First Class

First Class

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

Source: Wikipedia

Quality

Code Testing Anyone?

Drupal

A First Class CMS?

Drupal

A First Class CMS?

Drupal

A First Class REST Server?

Drupal

A First Class REST Server?

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.

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

Enter Cliche` Wisdom

Symfony2

Symfony2

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

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

Symfony2 Components

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

Symfony2 Components

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

Symfony2 Components

● Http Kernel● Http Foundation● Event Dispatcher

HTTP Kernel Component

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

HTTP Kernel Component

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)

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)

Symfony2 Components

● Http Kernel● Http Foundation● Event Dispatcher

HTTP Foundation Component

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

specification.

HTTP Foundation Component

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

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

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

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.

Symfony2 Components

● Http Kernel● Http Foundation● Event Dispatcher

Event Dispatcher Component

Event Dispatcher Component

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

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;

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.

Event Dispatcher Component

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

Routing Component

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

Routing Component

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

● Define routes

Routing Component

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

● Define routes

● Gather information about the incoming request

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

Routing Component

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

● Define routes

– YAML

– XML

– PHP

HTTP Kernel Component

HTTP Kernel Component

kernel.request event

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

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

HTTP Kernel Component

HTTP Kernel Component

HTTP Kernel Component

Resolve the controller based on routing info.

● ControllerResolver● getController()● getArguments()

HTTP Kernel Component

HTTP Kernel Component

kernel.controller event

● Initialize things for your app● Change the controller

HTTP Kernel Component

HTTP Kernel Component

HttpKernel::handle()

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

HTTP Kernel Component

HTTP Kernel Component

HTTP Kernel Component

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

HTTP Kernel Component

HTTP Kernel Component

kernel.response event

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

HTTP Kernel Component

Symfony2 Components

Symfony2 Components

TWIG Template Engine

Symfony2 Components

Doctrine Annotations

Symfony2 Components

Composer

top related