Upload
acquia
View
778
Download
1
Embed Size (px)
Citation preview
Everything You Need to Know About the Top 8 Changes in Drupal 8
Angela "@webchick" Byron May 26, 2015
What are we doing here?
• Go through top 8 changes for Drupal 8, in order of geekiness. ;)
• Walk through some of the bigger API changes in D8 for module developers
• Answers to frequently asked questions
• Q&A
What is Views module?• Create fully customizable:
• Admin listings
• Sidebar content
• Image galleries
• Slideshows
• XML/JSON output
• …with zero lines of code!
Translatable Everything!• Content
• Blocks
• Menus
• User Profiles
• Taxonomy
• Views
• Image styles
• Text formats
• Comments
• Feeds
• …and more!
• No contributed modules needed!
PHPTemplate is now Twig7.x: page.tpl.php 8.x: page.html.twig
<div id="page-wrapper"> <div id="page"> <div id="header"> <div class="section clearfix"> <?php if ($logo): ?> <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo"> <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" /> </a> <?php endif; ?>
<div class="layout-container"> <header role="banner"> {% if logo %} <a href="{{ front_page }}" title="{{ 'Home'|t }}" rel="home"> <img src="{{ logo }}" alt="{{ 'Home'|t }}"/> </a> {% endif %}
• Friendlier syntax for designers • Variables auto-escaped for better security
http://twig.sensiolabs.org
Modern PHP Best Practices• PHP 5.4+
• Classes/Interfaces
• Namespaces
• Traits
• Dependency Injection
• Most PSR-* standards
Powered by Symfony2
Tutorial: http://fabien.potencier.org/article/50/create-your-own-framework-on-top-of-the-symfony2-components-part-1
YAML, YAML everywhere7.x: example.info 8.x: example.info.ymlname = Example description = "Example module" core = 7.x files[] = example.test config = admin/config/example dependencies[] = node
name: Example type: module description: "Example module" core: 8.xconfig: admin.example dependencies: - node
• New required "type" property • No more files[] (we'll get to that later) • Paths now have machine names to
help prevent breakage(we'll get to that later, too)
Drupalism: Kinda-Sorta-INI-Like
"Proudly Invented Elsewhere": YAML
Classes, classes everywhere
sites/all/modules
example
▼
▼
example.test
7.xmodules
example
▼▼
8.x
src▼
ExampleForm.php
ExampleInterface.php
ExampleController.php
…
Pages, forms, blocks, etc. are now all object-oriented.
"Hello World" in Drupal 7
function example_menu() { $items['hello'] = array( 'title' => 'Hello world', 'page callback' => '_example_page', 'access callback' => 'user_access', 'access arguments' => 'access content', ); return $items; } function _example_page() { return t('Hello world.'); }
example.module
Drupalism: "ArrayPIs" ;)
"Hello World" in Drupal 8example.hello: path: '/hello' defaults: _content: '\Drupal\example\ExampleController::hello' requirements: _permission: 'access content'
example.routing.yml
<?php namespace Drupal\example; use Drupal\Core\Controller\ControllerBase; /** * Returns responses for Example module routes. */ class ExampleController extends ControllerBase { public function hello() { return new Response($this->t('Hello world.')); } }
src/ExampleController.php "Proudly Invented Elsewhere":
- YAML- PSR-4 Class Autoloader
- OO code
Defining a block: 7.xexample.module<?php function example_block_info() { $blocks['example'] = array( 'info' => t('Example block'), ); return $blocks; } function example_block_view($delta = '') { $block = array(); switch ($delta) { case 'example': $block['subject'] = t('Example block'); $block['content'] = array( 'hello' => array( '#markup' => t('Hello world'), ), ); break; } return $block; }
Drupalism: "Mystery Meat" APIs based on naming conventions
Defining a block: 8.x<?php
namespace Drupal\example\Plugin\Block;
use Drupal\block\BlockBase;
/** * Provides the Example block. * * @Block( * id = "example", * admin_label = @Translation("Example block"), * category = @Translation("Example") * ) */ class ExampleBlock extends BlockBase { public function build() { return array('hello' => array( '#markup' => $this->t('Hello world.') )); } }
src/Plugin/Block/ExampleBlock.php
"Proudly Invented Elsewhere":
- Annotations - APIs defined by
Interfaces
Read more about it!
https://api.drupal.org/api/drupal/8 https://www.drupal.org/documentation/developer/api
Every API change in Drupal 8
https://www.drupal.org/list-changes
Summary of Awesomeness• Improved Authoring
Experience
• Mobile First
• Views, expanded content modeling
• Multilingual++
• Configuration Management
• Twig & HTML5
• Web Services
• Modern, OO Code
• …and literally hundreds of other improvements!
• Full scoop: https://www.acquia.com/resources/ebooks/ultimate-guide-drupal-8
When is "when it's ready"?
Sometime after this graph hits zero.
https://www.drupal.org/drupal-8.0/get-involved
What's left in that list?
• Performance fixes/improvements
• Security fixes/improvements
• Beta-to-beta upgrade path
• Future-proofing (PHP7, Symfony 3, etc.)
beta -> rc -> 8.0.0• While count of critical issues >
0, create monthly beta releases (we are here!)
• If critical issues === 0, start bi-weekly release candidates (same as D6/D7 release windows) • Only critical fixes or extremely
non-disruptive (e.g. docs) patches committed during RC, to prevent regressions.
• Once count, rate, and nature of criticals seem manageable, set a release date >= 3 weeks later.
https://www.drupal.org/core/release-cycle#rc
alpha release beta RC1
we are here!
x
“WHEN IT’S READY”
What happens after 8.0.0?• Drupal 6 support dropped 3 months
after Drupal 8.0.0's release.
• Bug fix/security releases continue on monthly schedule as now in D6/D7.
• New "feature releases" of Drupal 8 every 6 months (8.1.x, 8.2.x…) with non-BC breaking improvements.
• Drupal 9 not branched until much later, when there's enough "meat" (completed change proposals which can't be committed to 8.x) to make a compelling product
• Drupal 8 enters "LTS" mode (security fixes only) after Drupal 9.0.0
D6 SUPPORT ENDS
8.2.08.1.0
NEWFEATURES
NEWFEATURES
…
NEW FEATURES
What about upgrades?• Upgrade path between 8.x versions
• Not supported in core yet; see https://www.drupal.org/project/head2head in contrib for now
• Migration path between major versions (6/7 => 8)
• Build out your Drupal 8 site as a new site, then migrate content, users, etc. over.
• Drupal 6 => 8 migrations already in! Drupal 7 => 8 migrations are in progress.
• Must port your own custom code; stick with well-used contrib modules if you can!
Kick-start your custom code porting
https://www.drupal.org/project/drupalmoduleupgrader
When will most people use D8?
Module/Theme developer
*Right now*!(still have time to
fix APIs!)
Majority
Once these lines cross
total
D8
D7
Early adopter
Once beta-to-betaupgrade path supported(port your own contribs)
Conservative
Platform’s proven, but community’s looking forward to Drupal 9.
Let the community be your guide.https://www.drupal.org/project/usage/drupal
I'm building a new site now. Should I start with D7 or D8?
http://www.slideshare.net/horncologne/why-drupal-8-why-now-aprmay-2015
Drupal 7 Drupal 8Public facing Internal / R&D / Prototype
Rapid deployment Less urgentLarge, complex needs Can be done with what's in core
Full feature set BrochurewareMission critical Experimental
Limited development team Expert development team, comfortable patching upstream
Developers more comfortable with procedural code
Developers more comfortable with OO code / Symfony
Sticking with D7?Here's how to get D8 hotness today!Drupal 8 Core Feature Drupal 7 Contrib Equivalent
WYSIWYG CKEditor: https://drupal.org/project/ckeditor
In-Place Editing Quick Edit: https://drupal.org/project/quickedit
Responsive Toolbar “Mobile Friendly Navigation Toolbar"https://drupal.org/project/navbar
Responsive Front-End Theme
Omega, Zen, Adaptive, etc. base themes
Responsive Admin Theme
Ember: https://drupal.org/project/ember
Responsive Images Picture: https://drupal.org/project/picture
Responsive Tables Responsive Tables: https://drupal.org/project/responsive_tables
Simplified Overlay Escape Admin: https://drupal.org/project/escape_admin
Multilingual Internationalization: https://www.drupal.org/project/i18n Entity Translation: https://www.drupal.org/project/entity_translation
Better Blocks Bean: https://www.drupal.org/project/bean
Configuration Management
Features: https://www.drupal.org/project/features
Web Services RESTful Web Services: https://www.drupal.org/project/restws