SlideShare ist ein Scribd-Unternehmen logo
1 von 22
For start – let’s think of this simple task!
All we would like to do is echo query string param to the screen..
// Route: hello?name=world

$hello = $_GET[‘name’];

printf(‘Hello %s’ , $hello); // Outputs ‘world’ and a warning



Think about that!
Symfony2 meets Drupal 8


Author: Ran Mizrahi (@ranm8)
        Open Source Department Leader
About CodeOasis

• CodeOasis specializes in advanced web
  solutions.

• Large variety of customers (from startups to
  retail companies and enterprises)

• Two main technology environments:
  • Open Source – PHP, JS and rich HTML5 and
    CSS3 client side applications
  • Microsoft .NET
Drupal is Awesome!!!

                    !?!?!!?
• End users - A way to create your own tailored made CMS
  - It’s great for our end users
• Salesmen - Known brand with many major use cases! -
  It’s great for a salesman
Drupal SUCKS for your’e looking
Well, maybe just if developers!! for a framework
Drupal Started as a CMS and evolved to a CMF!
The Problems:

• Larger websites are developed using Drupal content
  management abilities – Lots of code is written.

• BIG learning curve for both junior and experienced
  developers – Learn the “Drupal Way” (Procedural AOP)

• Lack of web development drivers/components

• Legacy code – Well, like every 11 years old software..
What is Symfony2??



"Symfony2 is a reusable set of standalone,
decoupled, and cohesive PHP components
that solves common web development
problems.”

Fabian Potencier – Symfony’s project lead
So, why use Syfmony2 in Drupal 8

• Symfony2 provides a great set of standalone,
  independent PHP components that solve common web
  problems. (HttpFoundation, ClassLoader,
  EventDispatcher, etc.)

• Move to the next generation PHP OOP features that are
  available from PHP 5.3 and above

• The PSR (PHP Standard Recommendation) standard –
  Allows easy-lazy-class-loader (by not bootstrapping code
  we don’t need).
Symfony2 Components in Drupal 8
PSR (PHP Recommended Standards)
• Set of PHP recommended standards by agreed and
  embraced by PHP most popular projects
  (Symfony, Drupal, Zend, CakePHP, Joomla, phpBB, etc.)

• Suggested coding standards for:
   • Naming conventions for autoloading (PSR-0)
   • Basic coding standards (PSR-1)
   • Coding style guide (PSR-2)
ClassLoader

• ClassLoader loads your project classes automatically if
  they follow the PSR-0 standard naming convention

• One universal class autoloader that follows PHP known
  standards

• Lazy-loading-class-loader
ClassLoader
Example

require_once __DIR__ . ’/ClassLoader/UniversalClassLoader.php';

use SymfonyComponentClassLoaderUniversalClassLoader;

$loader = new UniversalClassLoader();
$loader->register();

// Now we can register some namespaces…
$loader->registerNamespace(‘Symfony’, __DIR__ . ‘/src’);
HttpFoundation

• HttpFoundation wraps HTTP specification (PHP super
  globals - $_GET, $_SESSION, $_POST, $_COOKIE, $_FILE,
  etc. for request and echo, header, setcookie, etc. for
  response) with OO layer

• It provides abstraction for HTTP requests, responses,
  cookies, session, uploaded files, etc.
HttpFoundation
Let’s start with a simple task:
// Route: hello?name=world

$hello = $_GET[‘name’];

printf(‘Hello %s’ , $hello); // Outputs ‘world’ and a warning

It turns out to be not that simple, now we’ve got PHP warning:
// Route: hello?name=world

$hello = isset($_GET[‘name’]) ? $_GET[‘name’] : ‘World’;

printf(‘Hello %s’ , $hello); // Outputs ‘world’


OK, what now?! Yes, we have XSS issue )-: Let’s fix…
HttpFoundation

// Route: hello?name=world

$hello = isset($_GET[‘name’]) ? $_GET[‘name’] : ‘World’;

printf(‘Hello %s’ , htmlspecialchars($hello, END_QUOTES, ‘UTF-8’));
// Outputs ‘world’


Hard job for a simple task and makes our code look… UGLY!
HttpFoundation
This is how our code will look like using HttpFoundation:
// /hello?name=world
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;

$request = Request::createFromGlobals();
echo ‘Hello’ . $request->query->get(‘name’ , ‘World’); // Outputs ‘world’

And it’s great for unit testing (-:
class HelloTest extends PHPUnit_Framework_TestCase {
     public function testHello() {
           $request = Request::create('/?name=world', 'GET');
           $helloClass = new Hello();
           $content = $helloClass->sayHello();
           $this->assertsEquals(’Hello world’, $content);
     }
}
EventDispatcher
• The EventDispatcher is lightweight implementation of
  the Observer design pattern

• Provides the ability to dispatch and listen to events.

use SymfonyComponentEventDispatcherEventDispatcher;
use SymfonyComponentEventDispatcherEvent;

$dispatcher = new EventDispatcher();

$dispatcher->addListener(‘new_node’ , function(Event $event) {
     // React to the event
});

$dispatcher->dispatch(‘new_node’);
EventDispatcher

So how will it fit in Drupal (Larry Garfield’s prediction )

• Drupal 8 will have both hooks and EventDispatcher

• EventDispatcher will be closer to the core, hooks further
  out

• Drupal 9, maybe only event dispatcher ?!? I hope so (-:
Templates - Twig (Maybe?)

What is Twig?

• Twig is a template engine for PHP

• Uses it’s own template syntax, originally inspired from
  Jinja and Django (According to Wikipedia)

• Symfony2 uses Twig as main template engine

• Twig was written by Fabian Potencier
Templates - Twig (Maybe?)

PHPTemplate:
<div>
     <?php if ($content): ?>
     <span><?php echo $content; ?></span>
     <span><?php echo htmlspecialchars($content, ENT_QUOTES, ‘UTF-8’); ?>
</span>
     <?php endif; ?>
</div>
Twig:
<div>
     {% if content %}
     <span>{{ content }}</span>
     <span>{{ content|escape }}</span>
     {% endif %}
</div>
Templates - Twig (Maybe?)

Why Twig is good for us:

• Secure

• Front-end developer friendly (No PHP knowledge is
  required

• Not Drupal-proprietary.

• Great way to make sure that logics won’t find a place on
  Drupal templates (-:
Contact me @ranm8 on twitter
Mail : ranm@codeoasis.com

Weitere ähnliche Inhalte

Was ist angesagt?

Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJSPeter Drinnan
 
Survive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksSurvive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksJuho Vepsäläinen
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmineTimothy Oxley
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Anton Arhipov
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introductionNir Kaufman
 
Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)Deutsche Post
 
Agile JavaScript Testing
Agile JavaScript TestingAgile JavaScript Testing
Agile JavaScript TestingScott Becker
 
Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Matthew Barlocker
 
Composable and streamable Play apps
Composable and streamable Play appsComposable and streamable Play apps
Composable and streamable Play appsYevgeniy Brikman
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Sylvain Wallez
 
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma Christopher Bartling
 
Unit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaUnit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaAndrey Kolodnitsky
 
Unit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and NodeUnit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and NodeJosh Mock
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineGil Fink
 
Node Architecture and Getting Started with Express
Node Architecture and Getting Started with ExpressNode Architecture and Getting Started with Express
Node Architecture and Getting Started with Expressjguerrero999
 
SQLAlchemy Primer
SQLAlchemy PrimerSQLAlchemy Primer
SQLAlchemy Primer泰 増田
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with JestMichał Pierzchała
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaExoLeaders.com
 

Was ist angesagt? (20)

Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
 
Survive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksSurvive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and Tricks
 
Intro to testing Javascript with jasmine
Intro to testing Javascript with jasmineIntro to testing Javascript with jasmine
Intro to testing Javascript with jasmine
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 
Angularjs - Unit testing introduction
Angularjs - Unit testing introductionAngularjs - Unit testing introduction
Angularjs - Unit testing introduction
 
Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)
 
Agile JavaScript Testing
Agile JavaScript TestingAgile JavaScript Testing
Agile JavaScript Testing
 
Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1
 
Composable and streamable Play apps
Composable and streamable Play appsComposable and streamable Play apps
Composable and streamable Play apps
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
 
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
 
Unit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaUnit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and Karma
 
JVM
JVMJVM
JVM
 
Unit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and NodeUnit testing JavaScript using Mocha and Node
Unit testing JavaScript using Mocha and Node
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Node Architecture and Getting Started with Express
Node Architecture and Getting Started with ExpressNode Architecture and Getting Started with Express
Node Architecture and Getting Started with Express
 
SQLAlchemy Primer
SQLAlchemy PrimerSQLAlchemy Primer
SQLAlchemy Primer
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
 

Andere mochten auch

ярмарка инноваций в образовании для веб
ярмарка инноваций в образовании для вебярмарка инноваций в образовании для веб
ярмарка инноваций в образовании для вебssjaspb
 
Cheeky Carbon Presentation
Cheeky Carbon PresentationCheeky Carbon Presentation
Cheeky Carbon Presentationpauljl
 
Umk Eng 2 4 Nov.Ppt8
Umk Eng 2 4 Nov.Ppt8Umk Eng 2 4 Nov.Ppt8
Umk Eng 2 4 Nov.Ppt8ssjaspb
 
Publish2 Tour
Publish2 TourPublish2 Tour
Publish2 Tourscottkarp
 
El Besito
El BesitoEl Besito
El Besitotoispm
 
00 at the front desk - hotels
00   at the front desk - hotels00   at the front desk - hotels
00 at the front desk - hotelsLuciana Viter
 
Studying at UNH: Education and Research Opportunities
Studying at UNH: Education and Research OpportunitiesStudying at UNH: Education and Research Opportunities
Studying at UNH: Education and Research OpportunitiesAndrew Kun
 
euskara kontsumitzeko motibazioake
euskara kontsumitzeko motibazioakeeuskara kontsumitzeko motibazioake
euskara kontsumitzeko motibazioakeItxaso Ferreras
 
Salsatreetdance LG Plan
Salsatreetdance LG PlanSalsatreetdance LG Plan
Salsatreetdance LG Planguest4ff65
 
History of Computers (Jamie and Tiffany)
History of Computers (Jamie and Tiffany)History of Computers (Jamie and Tiffany)
History of Computers (Jamie and Tiffany)guestff967
 
EL GRAN RETO y Lo que logramos!!!!
EL GRAN RETO y Lo que logramos!!!!EL GRAN RETO y Lo que logramos!!!!
EL GRAN RETO y Lo que logramos!!!!Luis Montalvan
 
TV and the collective brain
TV and the collective brainTV and the collective brain
TV and the collective brainJenni Lloyd
 
16 golden rules to increase sales
16 golden rules to increase sales16 golden rules to increase sales
16 golden rules to increase salesSuhag Mistry
 
The steve jobs way
The steve jobs wayThe steve jobs way
The steve jobs waySuhag Mistry
 
In-Car Speech User Interfaces and their Effects on Driver Cognitive Load
In-Car Speech User Interfaces and their Effects on Driver Cognitive LoadIn-Car Speech User Interfaces and their Effects on Driver Cognitive Load
In-Car Speech User Interfaces and their Effects on Driver Cognitive LoadAndrew Kun
 

Andere mochten auch (20)

1119
11191119
1119
 
ярмарка инноваций в образовании для веб
ярмарка инноваций в образовании для вебярмарка инноваций в образовании для веб
ярмарка инноваций в образовании для веб
 
Cheeky Carbon Presentation
Cheeky Carbon PresentationCheeky Carbon Presentation
Cheeky Carbon Presentation
 
Umk Eng 2 4 Nov.Ppt8
Umk Eng 2 4 Nov.Ppt8Umk Eng 2 4 Nov.Ppt8
Umk Eng 2 4 Nov.Ppt8
 
1021
10211021
1021
 
Publish2 Tour
Publish2 TourPublish2 Tour
Publish2 Tour
 
El Besito
El BesitoEl Besito
El Besito
 
00 at the front desk - hotels
00   at the front desk - hotels00   at the front desk - hotels
00 at the front desk - hotels
 
1124
11241124
1124
 
Studying at UNH: Education and Research Opportunities
Studying at UNH: Education and Research OpportunitiesStudying at UNH: Education and Research Opportunities
Studying at UNH: Education and Research Opportunities
 
Primerafase
PrimerafasePrimerafase
Primerafase
 
euskara kontsumitzeko motibazioake
euskara kontsumitzeko motibazioakeeuskara kontsumitzeko motibazioake
euskara kontsumitzeko motibazioake
 
Salsatreetdance LG Plan
Salsatreetdance LG PlanSalsatreetdance LG Plan
Salsatreetdance LG Plan
 
History of Computers (Jamie and Tiffany)
History of Computers (Jamie and Tiffany)History of Computers (Jamie and Tiffany)
History of Computers (Jamie and Tiffany)
 
EL GRAN RETO y Lo que logramos!!!!
EL GRAN RETO y Lo que logramos!!!!EL GRAN RETO y Lo que logramos!!!!
EL GRAN RETO y Lo que logramos!!!!
 
0324
03240324
0324
 
TV and the collective brain
TV and the collective brainTV and the collective brain
TV and the collective brain
 
16 golden rules to increase sales
16 golden rules to increase sales16 golden rules to increase sales
16 golden rules to increase sales
 
The steve jobs way
The steve jobs wayThe steve jobs way
The steve jobs way
 
In-Car Speech User Interfaces and their Effects on Driver Cognitive Load
In-Car Speech User Interfaces and their Effects on Driver Cognitive LoadIn-Car Speech User Interfaces and their Effects on Driver Cognitive Load
In-Car Speech User Interfaces and their Effects on Driver Cognitive Load
 

Ähnlich wie Ran Mizrahi - Symfony2 meets Drupal8

Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkRyan Weaver
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformSébastien Morel
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)Fabien Potencier
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.jsChris Cowan
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHPEric Johnson
 
Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Fabien Potencier
 
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Mark Hamstra
 
NLUUG Spring 2012 - OpenShift Primer
NLUUG Spring 2012 - OpenShift PrimerNLUUG Spring 2012 - OpenShift Primer
NLUUG Spring 2012 - OpenShift PrimerEric D. Schabell
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 
HackU PHP and Node.js
HackU PHP and Node.jsHackU PHP and Node.js
HackU PHP and Node.jssouridatta
 
PHP Hypertext Preprocessor
PHP Hypertext PreprocessorPHP Hypertext Preprocessor
PHP Hypertext Preprocessoradeel990
 
Howtobuildyourownframework
HowtobuildyourownframeworkHowtobuildyourownframework
Howtobuildyourownframeworkhazzaz
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Fabrice Bernhard
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2Merixstudio
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesShabir Ahmad
 

Ähnlich wie Ran Mizrahi - Symfony2 meets Drupal8 (20)

Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 Framework
 
Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3Symfony 2.0 on PHP 5.3
Symfony 2.0 on PHP 5.3
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ Platform
 
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
symfony: An Open-Source Framework for Professionals (Dutch Php Conference 2008)
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHP
 
Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
 
NLUUG Spring 2012 - OpenShift Primer
NLUUG Spring 2012 - OpenShift PrimerNLUUG Spring 2012 - OpenShift Primer
NLUUG Spring 2012 - OpenShift Primer
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Current state-of-php
Current state-of-phpCurrent state-of-php
Current state-of-php
 
HackU PHP and Node.js
HackU PHP and Node.jsHackU PHP and Node.js
HackU PHP and Node.js
 
PHP Hypertext Preprocessor
PHP Hypertext PreprocessorPHP Hypertext Preprocessor
PHP Hypertext Preprocessor
 
Howtobuildyourownframework
HowtobuildyourownframeworkHowtobuildyourownframework
Howtobuildyourownframework
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
PHP MySQL Workshop - facehook
PHP MySQL Workshop - facehookPHP MySQL Workshop - facehook
PHP MySQL Workshop - facehook
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 

Mehr von Ran Mizrahi

Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 
How Testability Inspires AngularJS Design / Ran Mizrahi
How Testability Inspires AngularJS Design / Ran MizrahiHow Testability Inspires AngularJS Design / Ran Mizrahi
How Testability Inspires AngularJS Design / Ran MizrahiRan Mizrahi
 
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design PatternsHow AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design PatternsRan Mizrahi
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP TestingRan Mizrahi
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJSRan Mizrahi
 
Introduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitIntroduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitRan Mizrahi
 
Wix Application Framework
Wix Application FrameworkWix Application Framework
Wix Application FrameworkRan Mizrahi
 

Mehr von Ran Mizrahi (8)

Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
How Testability Inspires AngularJS Design / Ran Mizrahi
How Testability Inspires AngularJS Design / Ran MizrahiHow Testability Inspires AngularJS Design / Ran Mizrahi
How Testability Inspires AngularJS Design / Ran Mizrahi
 
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design PatternsHow AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design Patterns
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJS
 
Introduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim SummitIntroduction to node.js by Ran Mizrahi @ Reversim Summit
Introduction to node.js by Ran Mizrahi @ Reversim Summit
 
Wix Application Framework
Wix Application FrameworkWix Application Framework
Wix Application Framework
 

Kürzlich hochgeladen

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Ran Mizrahi - Symfony2 meets Drupal8

  • 1. For start – let’s think of this simple task! All we would like to do is echo query string param to the screen.. // Route: hello?name=world $hello = $_GET[‘name’]; printf(‘Hello %s’ , $hello); // Outputs ‘world’ and a warning Think about that!
  • 2. Symfony2 meets Drupal 8 Author: Ran Mizrahi (@ranm8) Open Source Department Leader
  • 3. About CodeOasis • CodeOasis specializes in advanced web solutions. • Large variety of customers (from startups to retail companies and enterprises) • Two main technology environments: • Open Source – PHP, JS and rich HTML5 and CSS3 client side applications • Microsoft .NET
  • 4. Drupal is Awesome!!! !?!?!!? • End users - A way to create your own tailored made CMS - It’s great for our end users • Salesmen - Known brand with many major use cases! - It’s great for a salesman
  • 5. Drupal SUCKS for your’e looking Well, maybe just if developers!! for a framework
  • 6. Drupal Started as a CMS and evolved to a CMF! The Problems: • Larger websites are developed using Drupal content management abilities – Lots of code is written. • BIG learning curve for both junior and experienced developers – Learn the “Drupal Way” (Procedural AOP) • Lack of web development drivers/components • Legacy code – Well, like every 11 years old software..
  • 7. What is Symfony2?? "Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP components that solves common web development problems.” Fabian Potencier – Symfony’s project lead
  • 8. So, why use Syfmony2 in Drupal 8 • Symfony2 provides a great set of standalone, independent PHP components that solve common web problems. (HttpFoundation, ClassLoader, EventDispatcher, etc.) • Move to the next generation PHP OOP features that are available from PHP 5.3 and above • The PSR (PHP Standard Recommendation) standard – Allows easy-lazy-class-loader (by not bootstrapping code we don’t need).
  • 10. PSR (PHP Recommended Standards) • Set of PHP recommended standards by agreed and embraced by PHP most popular projects (Symfony, Drupal, Zend, CakePHP, Joomla, phpBB, etc.) • Suggested coding standards for: • Naming conventions for autoloading (PSR-0) • Basic coding standards (PSR-1) • Coding style guide (PSR-2)
  • 11. ClassLoader • ClassLoader loads your project classes automatically if they follow the PSR-0 standard naming convention • One universal class autoloader that follows PHP known standards • Lazy-loading-class-loader
  • 12. ClassLoader Example require_once __DIR__ . ’/ClassLoader/UniversalClassLoader.php'; use SymfonyComponentClassLoaderUniversalClassLoader; $loader = new UniversalClassLoader(); $loader->register(); // Now we can register some namespaces… $loader->registerNamespace(‘Symfony’, __DIR__ . ‘/src’);
  • 13. HttpFoundation • HttpFoundation wraps HTTP specification (PHP super globals - $_GET, $_SESSION, $_POST, $_COOKIE, $_FILE, etc. for request and echo, header, setcookie, etc. for response) with OO layer • It provides abstraction for HTTP requests, responses, cookies, session, uploaded files, etc.
  • 14. HttpFoundation Let’s start with a simple task: // Route: hello?name=world $hello = $_GET[‘name’]; printf(‘Hello %s’ , $hello); // Outputs ‘world’ and a warning It turns out to be not that simple, now we’ve got PHP warning: // Route: hello?name=world $hello = isset($_GET[‘name’]) ? $_GET[‘name’] : ‘World’; printf(‘Hello %s’ , $hello); // Outputs ‘world’ OK, what now?! Yes, we have XSS issue )-: Let’s fix…
  • 15. HttpFoundation // Route: hello?name=world $hello = isset($_GET[‘name’]) ? $_GET[‘name’] : ‘World’; printf(‘Hello %s’ , htmlspecialchars($hello, END_QUOTES, ‘UTF-8’)); // Outputs ‘world’ Hard job for a simple task and makes our code look… UGLY!
  • 16. HttpFoundation This is how our code will look like using HttpFoundation: // /hello?name=world use SymfonyComponentHttpFoundationRequest; use SymfonyComponentHttpFoundationResponse; $request = Request::createFromGlobals(); echo ‘Hello’ . $request->query->get(‘name’ , ‘World’); // Outputs ‘world’ And it’s great for unit testing (-: class HelloTest extends PHPUnit_Framework_TestCase { public function testHello() { $request = Request::create('/?name=world', 'GET'); $helloClass = new Hello(); $content = $helloClass->sayHello(); $this->assertsEquals(’Hello world’, $content); } }
  • 17. EventDispatcher • The EventDispatcher is lightweight implementation of the Observer design pattern • Provides the ability to dispatch and listen to events. use SymfonyComponentEventDispatcherEventDispatcher; use SymfonyComponentEventDispatcherEvent; $dispatcher = new EventDispatcher(); $dispatcher->addListener(‘new_node’ , function(Event $event) { // React to the event }); $dispatcher->dispatch(‘new_node’);
  • 18. EventDispatcher So how will it fit in Drupal (Larry Garfield’s prediction ) • Drupal 8 will have both hooks and EventDispatcher • EventDispatcher will be closer to the core, hooks further out • Drupal 9, maybe only event dispatcher ?!? I hope so (-:
  • 19. Templates - Twig (Maybe?) What is Twig? • Twig is a template engine for PHP • Uses it’s own template syntax, originally inspired from Jinja and Django (According to Wikipedia) • Symfony2 uses Twig as main template engine • Twig was written by Fabian Potencier
  • 20. Templates - Twig (Maybe?) PHPTemplate: <div> <?php if ($content): ?> <span><?php echo $content; ?></span> <span><?php echo htmlspecialchars($content, ENT_QUOTES, ‘UTF-8’); ?> </span> <?php endif; ?> </div> Twig: <div> {% if content %} <span>{{ content }}</span> <span>{{ content|escape }}</span> {% endif %} </div>
  • 21. Templates - Twig (Maybe?) Why Twig is good for us: • Secure • Front-end developer friendly (No PHP knowledge is required • Not Drupal-proprietary. • Great way to make sure that logics won’t find a place on Drupal templates (-:
  • 22. Contact me @ranm8 on twitter Mail : ranm@codeoasis.com