introduction to new technologies in drupal 8
DESCRIPTION
Symfony, Twig, Backbone, Guzzle. What are these things? A lot of new libraries and technologies have been added to Drupal 8. This session will go through the new libraries and provide a brief introduction to them by looking at some history, and the effects of including them in Drupal. This will be a high-level introduction - not a deep technical walkthrough. It is suitable for everyone, regardless of skill level, who is interested in the building blocks of Drupal 8.TRANSCRIPT
WHO?Camilla Krag Jensen. @naxoc
I have been doing Drupal for 5 years.
You guys?
I work at
WHAT IS GOING ON IN THIS TALK?What is an external library?
Some history through Drupal releases.
For most of the new libraries - a short description.
AN EXTERNAL LIBRARYCode that lives somewhere else than on d.o. and is maintainedby people that are not nescessarily drupal people.
Can be used by other projects and benefit from collaborationfrom a lot of people.
In D8 - anything that lives in /vendor or /assets/vendor.
DRUPAL 4.7RELEASED IN MAY 2006
There were no external libraries apart from a forked version ofThe Incutio XML-RPC Library
We knew how to do things best ourselves
AS FOR JAVASCRIPT: THERE WAS VERY LITTLE» find . -name "*.js" ./misc/autocomplete.js./misc/collapse.js./misc/drupal.js./misc/progress.js./misc/textarea.js./misc/update.js./misc/upload.js
DRUPAL 5RELEASED IN JANUARY 2007
2 external libraries were added to Drupal.
One was really important - the other one not so much.
JQUERY!
Write less, do more.
Javascript tools with a really active community.
Everybody agreed that it was a great idea to get it in core, sofrom the proposal to when it was committed was less than 2months.
Issue: Pave the way for integration of jQuery into core
MORE JAVASCRIPT
The external library "Farbtastic" was added.
The total of Javascript files that shipped with Drupal was 11. 2of them external
DRUPAL 6RELEASED IN FEBRUARY 2008
No new external libraries were added.
MORE (DRUPAL) JAVASCRIPT IS SHOWING UPThere is a total of 23 JS files.
Still only 2 of them are external libraries.
DRUPAL 7RELEASED IN JANUARY 2011
Now things start happening.
The PHP library Archive tar by Vincent Blavet was added
There is a total of 85 JS files. A whopping 37 of them areexternal libraries. They are almost all jQuery libraries.
Most prominent is probably jQuery UI. It is a collection of UIcomponents like a datepicker, accordions and so on.
BUT WHAT ABOUT SIMPLETEST?Well, we only used the concept - not the library.
The impact was immensely positive, but it was still stuff we rolledourselves.
DRUPAL 8RELEASED SOME TIME IN THIS DECADE
Now the fun starts!
We have 193 Javascript files. Of them 87 are external.
JAVASCRIPT STATSJS-files Drupal-specific External Percent externalDrupal 4.7 7 0 0%Drupal 5 11 2 18%Drupal 6 23 2 9%Drupal 7 85 37 44%Drupal 8 193 87 45%
PHP LIBRARIES
SYMFONY2
Symfony2 is a lot of loosely coupled components.
It offers us a lot we didn't need to invent ourselves.
The first piece of Symfony2 was put in core in October 2011.Issue: Add Symfony2 HttpFoundation library to core
COMPOSERDependency manager
Inspired by package managers for other programminglanguages like Ruby and Node.
Only used in core for managing external dependencies.
A library declares its dependencies in a composer.js file.
PHPUNITWhew.
A mature testing framework that works well for testing OOPclasses.
Testing is much lighter loadwise with PHPUnit.
Has a mocking framework.
Cannot replace our version of simpletest but still is a gamechanger.
Issue: Start using PHPUnit for unit tests
ASSETICA Symfony component.
A way for Drupal to find stuff like your CSS or JS.
A way to include libraries.
There are 'filters' so that you can use LESS, SCSS, Coffeescript,etc. and have Assetic compile/massage your files.
Plays nice with Twig.Issue: Add Assetic component to core
GUZZLEA much needed upgrade of the way Drupal does HTTPrequests.
Useful for creating/using web services and a lot of other things.
Guzzle "just" wraps cURL.
Maintainers were very helpful in accommodating Drupal's useof the library.
Issue: Adopt Guzzle library to replace drupal_http_request()
DOCTRINE COMMONA bit like Symfony - a bunch of libraries like DB abstractionlayers etc.
We have incorporated the "common" library.
We use it for parsing annotations plugin definitions.Issue: Add the Doctrine Common PHP library
CKEDITORThis one I think many people know already.
Not having a WYSIWYG has been a serious lack in Drupal - aswell as a feature ;-)
It took a while to make a decision. Initially Aloha editor lookedlike it was going in.
Issue: Add CKEditor JS library to core
Editing text now looks like this straight out of the box.
TWIGSome guy is going to talk about that later this weekend while
swearing profusely.
JAVASCRIPT LIBRARIES
BACKBONE.JS AND UNDERSCORE.JSBackbone depends on Underscore.
Underscore is a set of low-level utilities for manipulatingarrays and objects.
Backbone is an MVC - Model - View - Controller solution forjavascript.
Gives a lot of freedom in building web apps.
In core so far - it is used on contextual links and in the toolbar.Issue: Add Backbone.js and Underscore.js to core
MODERNIZRA library that helps detecting older browsers that lackcapabilities.
Most websites use it, or something like it, today already.
Also makes it possible for other libraries to check for browsersupport.
Issue: Add Modernizr to core
QUESTIONS?