Skip to Content

Planet Drupal

Syndicate content - aggregated feeds in category Planet Drupal
Updated: 1 day 3 hours ago

Acquia Developer Center Blog: Chris Pliakas on How to Successfully Manage Software Projects

21 January 2016 - 11:15am
Chris Pliakas

Chris Pliakas, the director of Content Services Engineering at Acquia, has been leading the Acquia Content Hub project since May, 2015. A certified ScrumMaster, Chris has been working at Acquia since 2010: as a technical consultant, solutions architect, scrum master, and engineering manager.

Tags: acquia drupal planet
Categories: Drupal

Promet Source: Connect Site Users to Premium Content with Commerce License

21 January 2016 - 10:23am
Intro to Commerce License

Commerce License is a module that grants users access to premium digital resources by either a remote or local license.

This module is good for granting users a license to resources that live behind a paywall, such as training materials or videos. 

Categories: Drupal

YesCT: Get issues you care about ready for Global Sprint Weekend

21 January 2016 - 9:06am
Get issues you care about ready for Global Sprint Weekend Introduction

Drupal Global Sprint Weekend is January 30 and 31, 2016, and so far we have 34 locations all over the world.

This post will talk about what organizers and experienced contributors can do to get issues ready for sprint attendees to work on.

There is still time to add your small local sprint. Read the post and get your location listed!

Preparation Triage

Get an overview of your issue queue.

Review any RTBC issues, test (and if you are a maintainer, commit) them. Or, mark them needs work, giving specific actionable feedback. This will encourage past contributors to return, because they will see their work get in, or your review will show them you appreciate their work, and the specific feedback will help them know what to do next.

Reduce the size of your issue queue. Close issues won't fix, explaining why.

Postpone issues. Update the summary of issues to include information about what the issue is postponed on. Maybe whether it can be worked on or not depends on the phase of the release cycle the project is in. (Read the Core group for announcements about core release phases.)

Or, if it is blocked on another issue, postpone it and link to the blocking issue. (Update the blocking issue summary also noting the issues that are postponed on it.) Under the "Issue summary & relationships" field, make sure the issues are "related".

Eliminating issues you don't want people to work on will help them focus on the issues that are relevant. They will appreciate that.

Pick a few issues

Pick a few issues you want people to work on. Try to pick ones that involve a variety of skill sets and experience levels. List them in a way that is convenient for you. You could tag them SprintWeekend2016, and then use an advanced search to show just those issues. Or, make a google spreadsheet, or whatever works for you. If you have a couple issues that have very clear next steps documented and a small scope, tag them Novice. Read about what makes a good novice task.

For those issues, update the issue summary. Include a "Remaining Tasks" section which links to instructions for how to do each task. The dreditor browser plug in adds an "insert tasks" button to issue pages that puts an html table with links to tasks in an issue summary. Uncomment or comment out rows in the table depending on what remains to be done on your issue.

Give constructive feedback

Read the handbook page on constructive feedback. Whenever you leave feedback, thank the person for something specific that you would like them to do again. When making suggestions, give or link to examples. List specific next steps, give instructions or link to specifics, for example, link to one of the contributor tasks child pages.

Make a short list

Make a link to issues you want people to focus on. You might do this by using the advanced search for issues, filtering to: your project, SprintWeekend2016 tag, and issues where the status is: needs work and needs review (and maybe also active). Make a second link to an advanced search that also filters to issues tagged novice. (Or, filter to whatever criteria you want.) Share these links with others.

Write a post

Write a post about the topic you want to sprint on. Give some background information. Celebrate what already works. Link to a few of the issues you want to tackle at the sprint. Edit the Global Sprint Weekend wiki and put a link to your post next to your location. Or, if you will be remote only, list it under virtual.

Have questions?

Tweet using the #SprintWeekend hash tag, post a comment on the g.d.o wiki page, ask in the Mentoring Group, or ask in IRC in #drupal-contribute. -Cathy (YesCT)

Resources for Organizers
Categories: Drupal

OpenLucius: 12 cool modules for Drupal site builders | January 2016

21 January 2016 - 6:05am

The holidays are over for a while now, so it's about time for a new blog. In this article I'll discuss 12 modules that can help you get started with a great Drupal site:

1. Max image size

Categories: Drupal

Drupal core announcements: BigPipe in Drupal 8.1: please test!

21 January 2016 - 4:45am

Drupal 8.1 is accepting new features, and BigPipe is being proposed to be added as an experimental module to Drupal 8.1. BigPipe sends pages to clients in a way that allows browsers to show them much faster. It first sends the cacheable parts of the page, then the dynamic/uncacheable parts.

If you're interested or concerned, please give the BigPipe contributed module for Drupal 8.0.x a try, and even try to break it! The more confident we can be about its stability, the more likely it being part of Drupal 8.1 will be.

Categories: Drupal

Jeff Geerling's Blog: Configuring CloudFlare with Drupal 8 to protect the Pi Dramble

20 January 2016 - 7:46pm

In a prior post on the constraints of in-home website hosting, I mentioned one of the major hurdles to serving content quickly and reliably over a home Internet connection is the bandwidth you get from your ISP. I also mentioned one way to mitigate the risk of DoSing your own home Internet is to use a CDN and host images externally.

At this point, I have both of those things set up for (a Drupal 8 site hosted on a cluster of Raspberry Pis in my basement!), and I wanted to outline how I set up Drupal 8 and CloudFlare so almost all requests to are served through CloudFlare directly to the end user!

CloudFlare Configuration

Before anything else, you need a CloudFlare account; the free plan offers all the necessary features (though you should consider upgrading to a better plan if you have anything beyond the simplest use cases in mind!). Visit the CloudFlare Plans page and sign up for a Free account.

Categories: Drupal

Fredrik Jonsson: Running Drupal on Debian 8 with Apache 2.4, event MPM and PHP-FPM (via socks and proxy)

20 January 2016 - 5:02pm

I’m building a new Ansible playbook for setting up web servers with Debian 8. I have always used mod_php before and it has been very stable but have some well known drawbacks. Since Debian 8 comes with Apache 2.4 and PHP 5.6 I wanted to implement PHP-FPM that seems very promising.

With mod_php every Apache process will need to load PHP and therefor use a lot more RAM than needed, even for just serving static content like images and css. I have been running Lighttpd as a static file server to mitigate this problem.

With event MPM + PHP-FPM a plain Apache processes will deal with all static content and hand of PHP request to separate PHP-FPM processes. This will allow a server to handle more visitors with the same amount of RAM and I can skip Lighttpd.

I found surprisingly little information on how to get this working well for serving things like Drupal. So here are what I have found out from manuals, post on the Internet as well as my own testing.

This setup has not been tested in production yet! When it has I will try to remember to update this article. In local testing on a VirtualBox image with Debian 8 and 512 MB RAM it seems to work fine. I also run the same setup locally on OS X with good results.

Here are some performance test done with ab. These doesn’t say much more than that it seems to work and most likely can handle some load.

ab -k -l -n 1000 -c 10 -H "Accept-Encoding: gzip,deflate"

Requests per second:    526.01 [#/sec] (mean)

This was the front page of a local version of running Drupal 7, with page cache of course. I also tested with plain Drupal 8 and got around 300 request/sec, more or less what one would expect.

A plain html page looks like this.

ab -k -l -n 1000 -c 10 -H "Accept-Encoding: gzip,deflate" http://localhost/

Requests per second:    2466.39 [#/sec] (mean) Installation

Start by installing needed packages.

apt-get install apache2 apache2-dev php5-fpm mariadb-server

You most likely want some more php extensions as well, here are the ones I normally install for running Drupal.

apt-get install php5-cli php5-apcu php5-curl php5-dev php5-gd php5-imagick php5-json php5-mysql php5-mcrypt php5-twig php-pear graphicsmagick graphicsmagick-imagemagick-compat

As suggested in I will run PHP-FPM via mod_proxy_fcgi so lets activate that module.

a2enmod proxy_fcgi

This will automatically activate the proxy module as well since it is a dependency. I also activate auth_digest, expires, rewrite and ssl on my servers. Rewrite is needed for Drupal to get clean URLs.

Apache and PHP-FPM configurations

Debian by default set up PHP-FPM to listen on a unix socket and since that should perform a bit better than a TCP socket I will use that. The most important setting is “max_children”. With Drupal each PHP process will use something like 20-40 MB typically, can be a lot more for some site so you simply need to test and see.

If your Drupal site use 30 MB per process setting “max_children” to 10 means that PHP will use up to about 10 * 30 MB = 300 MB of RAM. A good resource for figuring out what is the best settings is this blog post Adjusting child processes for PHP-FPM (Nginx) · MYSHELL.CO.UK

listen = /var/run/php5-fpm.sock
pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6
pm.max_requests = 2000

The default MPM for Apache 2.4 (at least on Debian) is event MPM and since that is the most modern and best performing MPM there is no reason not to use it. I run with default setting and that should work well for most small servers. If needed I may up the value on ThreadsPerChild but I don’t think that will be needed on my servers.

# event MPM
# ServerLimit: upper limit on configurable number of processes (default = 16)
# StartServers: initial number of server processes to start (default = 3)
# MinSpareThreads: minimum number of worker threads which are kept spare (default = 25)
# MaxSpareThreads: maximum number of worker threads which are kept spare (default = 75)
# ThreadLimit: upper limit on the configurable number of threads per child process (default = 64)
# ThreadsPerChild: constant number of worker threads in each server process (default = 25)
# MaxRequestWorkers: maximum number of worker threads (default = ServerLimit x ThreadsPerChild)
# MaxConnectionsPerChild: maximum number of requests a server process serves (default = 0)
<IfModule mpm_event_module>
  ServerLimit             16
  StartServers            3
  MinSpareThreads         25
  MaxSpareThreads         75
  ThreadLimit             64
  ThreadsPerChild         25
  MaxConnectionsPerChild  2000
</IfModule> Apache vhost setup

Here we then come to the part that caused me the biggest problem. How to get PHP-FPM to only run the php files I wanted and not everything. The Apache wiki page above suggest using ProxyPassMatch but it turns out that that overrides any restrictions set in e.g. a Files/FilesMatch directive. For Drupal I want to block access to files like update.php and cron.php so another solution was needed.

I found the solution in a post from Mattias Geniar Apache 2.4: ProxyPass (For PHP) Taking Precedence Over Files/FilesMatch In Htaccess. His suggestion to use a SetHandle in a FileMatch directive seems to work very well.

This is how I set up a vhost for serving Drupal.

<VirtualHost *:80>
  DocumentRoot /var/www/customers/example/web
  ErrorLog /var/www/customers/example/logs/error_log
  CustomLog /var/www/customers/example/logs/access_log combined
  <Directory "/var/www/customers/example/web">
    Options FollowSymLinks
    AllowOverride None
    Include /var/www/customers/example/web/.htaccess
    <IfModule mod_proxy_fcgi.c>
      # Run php-fpm via proxy_fcgi
      <FilesMatch \.php$>
        SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost"
    # Only allow access to cron.php etc. from localhost
    <FilesMatch "^(cron|install|update|xmlrpc)\.php">
      Require local

Notice that I include the .htaccess file. I have set “AllowOverride None” to prevent Apache from looking for and automatically include any .htaccess files it finds. This improves performance a bit but one needs to remember to reload Apache when changes are made to the .htaccess file.

Extra security configurations in Apache for Drupal

Drupal put .htaccess in the files folder and some other places for security reasons. The following is an example how to add the same security configurations directly in an Apache conf file. The DirectoryMatch regex most likely needs adjustment for your directory structure.

# Security setting for files folder in Drupal.
<DirectoryMatch "^/var/www/.*/web/(.+/)?(files|tmp)">
  # Turn off all options we don't need.
  Options -Indexes -ExecCGI -Includes -MultiViews

  # Set the catch-all handler to prevent scripts from being executed.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
  <Files *>
    # Override the handler again if we're run later in the evaluation list.
    SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003

  # If we know how to do it safely, disable the PHP engine entirely.
  <IfModule mod_php5.c>
    php_flag engine off

# Security setting for config folder in Drupal.
<DirectoryMatch "^/var/www/.*/web/(.+/)?(private|config|sync|translations|twig)">
  <IfModule mod_authz_core.c>
    Require all denied

  # Deny all requests from Apache 2.0-2.2.
  <IfModule !mod_authz_core.c>
    Deny from all
  # Turn off all options we don't need.
  Options -Indexes -ExecCGI -Includes -MultiViews

  # Set the catch-all handler to prevent scripts from being executed.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
  <Files *>
    # Override the handler again if we're run later in the evaluation list.
    SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003

  # If we know how to do it safely, disable the PHP engine entirely.
  <IfModule mod_php5.c>
    php_flag engine off
Categories: Drupal

Darren Mothersele: Surviving - and thriving - during the transition to Drupal 8

20 January 2016 - 4:00pm

This is my proposal for a session at the upcoming Drupal Camp in London.

Drupal is going through some big changes. And, so is the world. Now may be an unsettled period, but, times of disturbance can also be times of great opportunity.

I will share my experiences with Drupal and my research into how the web and society are transforming. This will include my personal manifesto and ideas about Drupal's role in the future of the web.

The Drupal community helped me transform in many ways. I have had the opportunity to work on some of the biggest, flagship Drupal websites, and in teams of all sizes. I've grown and advanced as a developer and a human.

There have also been difficult times. These have included my own personal challenges, and stories I have heard from others. In my work at Ideation Networks I sit with clients as they weigh up the pros and cons of Drupal. Many organisations feel they have been burnt by Drupal. And, for some, PHP (and by association Drupal) is just not cool.

But, on the whole, these are exciting times for Drupal.

Drupal 8 is the biggest achievement of our community to date. The latest version has been completely rewritten to use modern object-oriented PHP. We refer to this process as "getting off the island". It means dropping the "not invented here" philosophy, and embracing the wider PHP community.

Drupal as a product, a community, and a movement, is our co-creation.

We have all played a part in Drupal's success: Dries and the core development team; the wider community of contributors; the attendees of Drupal camps and conferences; people who talk about Drupal; and the developers, agencies, companies and users that drive Drupal's adoption.

In this session I will attempt to answer these questions:

What have we gained, and what have we sacrificed along the way?

NGOs, charities, smaller organisations, and hobbyists made up Drupal's traditional user-base. Have we shunned them as we've chased the enterprise client and big budget projects? Or, does Drupal 8 bring more of these users back into the fold?

Now that we've got this amazing platform, what do we do with it?

The Egyptian Revolution of 2011 is just one example of the web enabling real change in the world. How does Drupal fit into the bigger picture? How can we empower more positive change in the world?

Where do we go next? How can Drupal continue to transform and grow?

Everyone is talking about front-end frameworks, progressive decoupling, big pipe, micro-services. Innovation is more than just jumping on bandwagons. Considered from a deeper place, what do these trends tell us about the real changes that are happening? How does Drupal embrace these changes?

I'm excited. There are some tensions to resolve, and some challenges ahead, but also big opportunities.

Join me for this session. Let's explore transformation of our world, the web, Drupal, and ourselves.

Categories: Drupal

Cocomore: Starting in the new year with Drupal 8 – Cocomore workshop in January 2016

20 January 2016 - 3:00pm

On January 8th our developers camte together to have a Drupal 8 workshop. You can read here, what they experienced and what is new for the Frontend with Drupal 8!

Categories: Drupal

Palantir: The Secret Sauce podcast, Ep. 01

20 January 2016 - 8:49am

This is the first in our weekly bonus podcast that deals with shorter tips and resources that will help you with some straightforward facet of your web project. It's a compliment to our monthly, long-form podcast On the Air With Palantir. That's why we call it the Secret Sauce.

Some episodes will focus on strategy, design, metrics, or other such topics, while others will be more technical in nature. Whatever the focus, we want these to be useful for you, so we draw from our real world experience.

iTunes | RSS Feed | Download

This time around Allison Manley lets Larry Garfield take the mic to talk about Drupal 8, how you can prepare for it properly, and how the changes in this new version push us toward a content strategy approach. While applicable to anyone considering Drupal 8, this particular episode is mostly technical in nature and geared more toward site builders and developers.

Look for the Secret Sauce bonus podcast released weekly on Tuesdays.

Want to talk Drupal 8, and see how our consulting services can get you on the right path? Let's schedule a time to talk.

Categories: Drupal Featured Case Studies: City of Chicago, Office of the City Clerk Website

20 January 2016 - 8:16am
Completed Drupal site or project URL:

Chicago’s Office of the City Clerk (“OCC”) is the most visited office in Chicago government. Citizens regularly use the OCC’s primary website to get information about how to purchase Chicago city vehicle stickers, search prior City Council agendas and legislation, and tune in for the live streaming of Chicago City Council meetings.

The office is known for its technological innovation: it recently moved the purchase of Chicago city vehicle stickers to a year-round online purchasing system, replacing the nearly century-old process of having citizens stand in line once a year to purchase such stickers in person. That mission of innovation was not reflected in its old website, however. The old website was a mix of WordPress and custom PHP files, with document storage split across multiple domains.

On the old site, maintenance was difficult, with simple site content changes often requiring a knowledge of HTML and CSS that OCC staff didn’t have. Additionally, the site was not easily used from mobile devices, despite the fact that nearly 50% of the site traffic came from such devices. OCC knew that it needed an overhaul for its website in order to serve the residents of Chicago for years to come.

Key modules/theme/distribution used: Feed ImportCORSSecurity ReviewSecurity KitDraggableViewsViews DatasourceTeam members: Marc DeLayDrupalKellyTgjangelo
Categories: Drupal

ActiveLAMP: Creating a deployable Docker image with Jenkins - Part 4

20 January 2016 - 6:30am

My previous posts talked about getting your local environment setup using the Drupal Docker image with Vagrant. It’s now time to bake a Docker image with our custom application code within the container, so that we can deploy containers implementing the immutable server pattern. One of the main reasons we starting venturing down the Docker path was to achieve deployable fully baked containers that are ready to run in whatever environment you put them in, similar to what we’ve done in the past with Packer, as I’ve mentioned in a previous post.

Categories: Drupal

Modules Unraveled: 152 What to Do About Drupal 6 End of Life on Feb 24th 2016 with David Snopek - Modules Unraveled Podcast

19 January 2016 - 10:00pm
Published: Wed, 01/20/16Download this episodeDrupal 6 End of Live
  • What does Drupal 6 EOL mean?
  • When is Drupal 6’s End-Of-Life (EOL)?
    • February 24th
  • Why is support for Drupal 6 being dropped by the Drupal project in the first place? (ie. why does our community even do this?)
    • What makes Drupal 6’s End-of-Life (EOL) different than previous ones (ie. Drupal 5)?
  • What, specifically, will happen after February 24th?
    • All D6 modules will be marked as “unsupported” on - which will mean the ‘update’ module will start telling you that ALL your modules are out-of-date
    • Also, the status information that the ‘update’ module uses could go away at any time - so, you’ll no longer be able to rely on that in general (myDropWizard or another vendor MAY create a replacement for the ‘update’ module…)
    • The Drupal security team will no longer be making Security Advisories (or coordinating security releases)
    • In general, most module maintainers will no longer pay attention to Drupal 6 issues and will stop making new releases
  • What should people with Drupal 6 sites do?
    • Archive the site, or
    • Plan upgrade, and
    • If you can’t upgrade by February 24th, buy Drupal 6 Long-Term Support from one of the “official” vendors:
  • What makes the “official” vendors special (vs. any other vendor)?
    • Get confidential information from Drupal security team
    • Agree to follow security team processes and release all security patches publicly
    • Were vetted by the Drupal security team
  • How will the Drupal 6 LTS work?
    • Same process as security team - but work done by vendors rather than security team
    • Will publish patches on the D6LTS project:
    • Likely, but not 100% decided:
      • Announce new patches on the D6LTS issue queue
      • Make new Pressflow 6 releases with the Drupal core patches
  • So, can the community get this without working with a vendor?
    • Yes!
    • But each vendor only supporting those modules their customers depend on
    • And what about security issues that hackers find first?
  • What does do? And how is your offer different than the other vendors?
    • “ provides 24/7 support and maintenance from Drupal experts for a fixed monthly fee. We keep your site online, up-to-date and secure!”
    • Our Drupal 6 Long-Term Support offer:
      • making security fixes
      • fixing bugs
      • performing one-off maintenance and support tasks on request
      • getting your site back online in the case of an outage, and
      • remediation if your site gets hacked.
    • Basically, keep your site online and secure until you’re ready to upgrade - and we can help with a D7 or D8 upgrade as well
  • Technical questions about how we do what we do?
  • Your offering includes a whole bunch of stuff! Why don’t you have a “security updates only” offering?
Episode Links: David on drupal.orgDavid on TwittermyDropWizard.comEmail myDropWizardD6LTS ProjectD6 Long-term-support Official VendorsTags: Drupal 6Securityplanet-drupal
Categories: Drupal

DrupalCon News: Join us at the sprints

19 January 2016 - 2:17pm

If you’ve been using Drupal for more than a day, chances are that you’ve benefitted from some of the work done at DrupalCon sprints. Some of the most important breakthroughs for the project are made by sprinters at DrupalCon, and attending sprints is a great way to give back to the project you love.

Categories: Drupal

Agaric Collective: Moving towards a service oriented architecture

19 January 2016 - 12:25pm

In this installment of our case study about working with long term projects I will explain the architectural decisions made by our client, ZEIT ONLINE, regarding the relaunch of their digital subscription platform. Please refer to part 1 of this series for basic information about the project and a discussion of how to deal with the evolution of programming languages and operating systems.

Early on our client had decided to split up the platform into separate services that communicate via HTTP. This would allow them to develop those components using the most suitable technology for each, as well as allowing the services to progress more independently. The existing platform already used a separate service for authentication and storing user profile information. We took it from there and worked with the client to take it a step further.

First we identified the major logical components of the platform:

  • User accounts
  • Product presentation
  • Checkout
  • Order management (including data exchange with fulfillment provider)
  • Content delivery (via HTTP and E-Mail)

When considering how to divide the whole into services, we found it helpful to elaborate on the interfaces between them. The overall idea here is similar to what is accomplished by writing tests first: by grasping how you will consume an interface, it helps define the implementation more succinctly. In order to keep it simple we imposed a constraint on communications between services: When responding to any request, a service must not depend upon another HTTP request to a third party. That way developers would not have to deal with complex dependencies in their development environment and errors would be easy to locate.

Another important consideration was not to do too many things at the same time. Drupal 6 was fulfilling the roles of delivering content and product presentation to the client's satisfaction and the functionality was provided by a small amount of modules. As an upgrade of those parts to Drupal 7 would be straight forward, that was the direction taken for those items. A new client side order form had been developed already and was in experimental use as an alternative to the Ubercart checkout process.

That left the order management as a candidate for a new service. It needs to take orders from the client side order forms, store them, and send them to the fulfillment provider. It would also need to receive updates about the states of an order from the fulfillment provider. Agaric was asked to develop that component and picked Flask as a framework. That was a subjective choice, any other technology for building web applications could have been employed as well.

In upcoming posts I will cover the individual components and how they fulfill the goals of the overall architecture. ZEIT ONLINE is happy with the architecture and is currently moving further along those lines.

Categories: Drupal

Drupal @ Penn State: Implementing drupal_static on function with dynamic variables

19 January 2016 - 9:36am

Using drupal_static() on your helper functions is a great habit to get into when developing your modules. Drupal static ensures that your function will only run through its logic once during the bootstrap process. Depending on your functions logic, this can start saving lots of processing time if your function is being called multiple times during bootstrap or page load.

Implementing drupal_static

Let's take the following function for example. Here is helper function takes a url string from the ELMSLN network and breaks it up into identifiable parts.

Categories: Drupal

Drupal @ Penn State: Purespeed: Cache bin backends

19 January 2016 - 9:36am

Drupal is fantastic at caching itself (I mean, you've gotta be with a code base this hefty).  Drupal 8 will see the dawn of render cache in core which is why most metrics you see of D8 are uncached (because it's basically cheating its so fast cached). If you want to play around with Render Cache in D7, it can be done but still needs some work ( actually runs Render Cache backport to handle comments in issue queues among other things).

Categories: Drupal

Drupal @ Penn State: Purespeed: PHP tuning

19 January 2016 - 9:36am

The Buzz is all about PHP 7, and rightly so, it's pretty incredible some of the performance metrics its pulling even relative to Facebook's HHVM. Brad Fisher wrote about a one-line installer to get up and going with PHP 7 if you want to play around with it. But then reality sets in...

Categories: Drupal

SitePoint PHP Drupal: Tutorial on Using Drupal 8 Plugin Derivatives Effectively

19 January 2016 - 9:00am

In an earlier tutorial, we looked at the Drupal 8 plugin system and how to create our very own custom plugin type. We’ve seen that much of the functionality declared via _info hooks in Drupal 7 has been replaced by these plugins. Our use case was very basic and it allowed each instance of such functionality to be declared manually via a new plugin class and associated form.

But what if we needed such instances declared dynamically depending on some factors external to our little subsystem? For example, when declaring _info hooks in Drupal 7, we can get a list of something, loop over it and declare a new item in the returned array for each individual something. The menu system does this in order to provide a new block for each menu that either comes with Drupal core or is later created through the UI.

So what about Drupal 8? We’ve seen that for each plugin of a certain type we need to declare a different PHP class. To create a new block, we need a new class. To create another block, we need another class. So where would that looping we see in Drupal 7 take place? The short answer to this is: within a plugin derivative.

In this article we will explore the long answer to that and learn what derivates are and how we can use them. For the latter, we will build an example inside the demo module that can be found in this git repository and which should hopefully help us better understand what’s going on. For a slightly more complex example, the Menu system is great as it provides an individual block for each of its menus (similar to Drupal 7 but using plugins).

What we are going to do is actually very simple. We are going to implement basic Node Block functionality by which for all the article nodes on our site we will have a block. Ridiculous? Sure. Should we be doing this for all the nodes on our site? Definitely not! But it’s a very basic implementation meant to keep things short and demonstrate the use of the plugin derivatives.

Plugin Derivatives

Plugin derivatives are the way through which a plugin of a certain type can be represented in the system as multiple instances of itself. In other words, a plugin can reference a deriver class which is responsible for providing a list of plugin definitions that are based on the initial plugin (start from the same base definition) but have slightly different configuration or definition data. The SystemMenuBlock we referred to above is a great example. It’s a single plugin which has as many derivatives as there are menus on the site.

To go a bit deeper, when a list of all the plugins of a certain type is requested, the plugin manager uses its discovery mechanism to load all the plugins of this type. If that mechanism is decorated with the DerivativeDiscoveryDecorator, the manager will be able to also retrieve derivatives. In order to do this, the derivative discovery looks for a deriver class on each plugin and, if it finds one, asks it for this list.

Continue reading %Tutorial on Using Drupal 8 Plugin Derivatives Effectively%

Categories: Drupal

Acquia Developer Center Blog: Drupal 8 Module of the Week: Services

19 January 2016 - 7:17am
Reena Leone

Each day more Drupal 7 modules are being migrated over to Drupal 8. In this series, the Acquia Developer Center is profiling some of the most prominent, useful modules that have crossed the chasm. This week: Services.

Kyle Browning, Drupalist since 2006 and Technical Consultant at Acquia, provides some insight on this Top 150 Drupal module he maintains.

What does the Services module do?

Tags: servicesdrupal 8acquia drupal planet
Categories: Drupal

about seo